Save the date! Join us on October 16 for our Product Ops launch event. Register here.
Jun 26, 2020 08:16 AM
I’m trying pass a string as a field - which I’m pretty sure I’ve seen @kuovonne explain someone else that it’s possible.
const mainCur = base.getTable("Contacts").getView("Currency");
const mainCurMatchField = 'Currency name'
const mainCurrencyConversion = async (tableView, matchField) => {
let selectRecords, gbp, eur, usd
selectRecords = await tableView.selectRecordsAsync();
[gbp, eur, usd] = await getConversion('test')
for (let record of selectRecords.records){
console.log(record.getCellValue(matchField))
}
};
await mainCurrencyConversion(mainCur, mainCurMatchField)
I’m trying to get record.getCellValue(matchField) to use ‘Currency name’ as field name. I’ve tried to wrapped it in {}, but so far I’ve been out of luck.
Is this possible or is it me who got this wrong?
Solved! Go to Solution.
Jun 26, 2020 12:59 PM
Hi @Kim_Trager1 - I think you are on the right lines. I know this isn’t you exact scenario, but this works for me:
let table = base.getTable('Table 1');
let query = await table.selectRecordsAsync();
let myField = 'Name of Person';
let results = (field) => {
for (let record of query.records) {
console.log(record.getCellValue('Name of Person'))
console.log(record.getCellValue(field))
}
}
results(myField);
based on this table:
So referring to the field by its name explicitly or by passing its name through as an argument in the function gives me the same output.
Jun 26, 2020 11:41 AM
I don’t see where matchField
has been defined.
Jun 26, 2020 12:59 PM
Hi @Kim_Trager1 - I think you are on the right lines. I know this isn’t you exact scenario, but this works for me:
let table = base.getTable('Table 1');
let query = await table.selectRecordsAsync();
let myField = 'Name of Person';
let results = (field) => {
for (let record of query.records) {
console.log(record.getCellValue('Name of Person'))
console.log(record.getCellValue(field))
}
}
results(myField);
based on this table:
So referring to the field by its name explicitly or by passing its name through as an argument in the function gives me the same output.
Jun 28, 2020 09:31 AM
Hi @JonathanBowen - Bizzare I tried so many things - except apparently from the most straight forward way.
But thanks for pointing out the obvious to me
Jun 28, 2020 09:32 AM
Um, yeah - I see, it is defined here:
await mainCurrencyConversion(mainCur, mainCurMatchField)