Skip to main content

Multiple linked records in script

  • June 20, 2023
  • 1 reply
  • 0 views

Forum|alt.badge.img+1

Hi,

I'm trying to create a script that copies a record in another table, and there is a record linked to another table (agents). If i try the script when the record has 1 agent it works, but it crashes if it's more then one agent. 

This is the problematic part of the code. How can i fix this?

 

 
let recordID = await task.createRecordAsync({
'Detail' : inputConfig.detail,
'Agent' : [{id:inputConfig.agent.toString()}],
});

1 reply

Forum|alt.badge.img+18

Is inputConfig.agent outputting an ID string?

Try replacing 'Agent' : [{id:inputConfig.agent.toString()}], with

'Agent' : inputConfig.agent.map(a => ({id: a})),
 

Reply