Help

Save the date! Join us on October 16 for our Product Ops launch event. Register here.

Multiple linked records in script

Topic Labels: Automations
514 1
cancel
Showing results for 
Search instead for 
Did you mean: 
CSCDeveloping
4 - Data Explorer
4 - Data Explorer

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 1

Is inputConfig.agent outputting an ID string?

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

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