I am having trouble getting a script to automatically generate records from two lists: bonus plan and staff list into “bonustable”. I was able to set up the automation steps to find the corresponding lists from the bonus plan and staff list. I have tried AI to get the script but it is not iterating each item from the input list. I also want to input the value year-month from the previous step of automation so that the created record already has year-month linked.
Essentially I am looking for the following output:
Jane / Bonus Plan A / 2025-03
Jane / Bonus Plan B / 2025-03
Jane / Bonus Plan C / 2025-03
Ben / Bonus Plan A / 2025-03
Ben / Bonus Plan B / 2025-03
Ben / Bonus Plan C / 2025-03
Script is as follows:
// Access input variables from previous automation steps
const inputConfig = input.config();
const bonusPlanNames = inputConfig.bonusPlanNames;// Array of Bonus Plan names (primary field)
const staffNames = inputConfig.staffNames;// Array of Staff names (primary field)
const yearMonth = inputConfig.yearMonth;// String in "YYYY-MM" format
I would probably just use a repeating group on the first list of records. Then ask chatgpt to write you a script to process that one record and match it with another record in your second table (depending on how you want to match the records). Then create a record in your third table which links to the first two. This way you ensure each record is processed and chatgpt can write a simpler script.