Help

Lookup .valuesByLinkedRecordId doesn't return within Automation Script?

Topic Labels: Automations
460 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Karlstens
11 - Venus
11 - Venus

When I run my following code within the Scripting App, it returns an overly useful object that I can easily sort and use to update my record with.

 

 

let sortedResults = membersRecords.records
  .filter( member => member.getCellValue("Result Date") !== null)
  .forEach( member => (
    console.log(JSON.stringify(member.getCellValue("Result Date").valuesByLinkedRecordId)),
    console.log(member.getCellValue("Result Date"))
  ));

 

 

Note how valuesByLinkedRecordId, which is a lookup field set to return the date, returns the below object - and how in this object the records are incorrectly ordered by date.

Karlstens_0-1683325472023.png

This returned valuesByLinkedRecordId object is fantastic, as it can be processed into an object that's sorted by date and then stamped back into the associated Linked Field so that the records are then in the date sorted order.

 However, when I attempt to adapt my Script App code (which cycles through all records in the table) into an Automation script that's nested within a "Repeat for each" loop, I find that valuesByLinkedRecordId returns undefined. It's like it doesn't exist within the Automation environment?

 

 

const {memberId} = input.config()

const memberTable = base.getTable("Members")
const member = await memberTable.selectRecordAsync(memberId,
{
    fields : [ "Member Name", "All Results", "Result Date"]
})

console.log(member)
console.info(member.getCellValue("Result Date"))

const membersRecords = await memberTable.selectRecordsAsync(
{
    fields : [ "Member Name", "All Results", "Result Date"],
    recordIds: [memberId]
})

let sortedResults = membersRecords.records
  .filter( member => member.getCellValue("Result Date") !== null)
  .forEach( member => (
    console.log(JSON.stringify(member.getCellValue("Result Date").valuesByLinkedRecordId)),
    console.log(member.getCellValue("Result Date")),
    console.log(member.getCellValue("All Results"))
  ));

 

And the returned Lookup field is watered down significantly - with only the string data returned and not the associated linked record.

(A different record, but hopefully you get the idea)

Karlstens_1-1683325802588.png

Have I missed something obvious here? Why is my returned Lookup Field data watered down within an Automation, but not in a script? I've tried both

selectRecordAsync(memberId})
selectRecordsAsync( { recordIds: [memberId]})
 

Both returning the same undefined result within an Automation. 🙁

 
0 Replies 0