Help

Re: record.getCellValue on a Link field gives back string[] in automation but object[] in scripting app

665 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Philipp_Dowling
4 - Data Explorer
4 - Data Explorer

I have a script that I run through an automation but sometimes also want to run manually. Ideally, I’d like to use the exact same code in both so I don’t have to maintain two scripts. However, the API seems to behave differently in the two environments. Using this exact same code block:

let myTable = base.getTable('Some Table');
let query = await myTable.selectRecordsAsync();

for (let record of query.records){
    let val = query.records.map(record => {
        let vals = record.getCellValue("Linked Stuff");  // this field references another table
        console.log(vals);
        // ... the rest doesn't matter
        return 1 // some kind of sum over the records in vals, etc.
    }
}

the log statement shows that in the scripting block, “vals” is an array of objects:
Screenshot 2022-01-12 at 14.57.19

However, the same code run in an automation (debug view) produces an array of strings in that variable:
Screenshot 2022-01-12 at 14.58.05

Is this a temporary bug? Which behaviour should I expect in general? I can work around this for now but of course I’d like to avoid doing in-code type checks all over the place. Thanks!

1 Reply 1

Are you sure you are using straight scripting both times? In scripting (either an automation script or scripting app) you get an array of objects. When using the REST api, you get an array of strings.