I’m importing some records of clients via csv. One column in the csv contains multiple appointment dates per client.
I want the clients to go into my Clients form. The Clients form has a Link to Form field called Appointments. It’s a 1:M field and “Show Inverse Relationship” is checked.
I need the clients to be imported as records in the Clients form, and the multiple dates per client from the csv to be entered as child records in the Appointments form.
I don’t think there’s a way to do that all in import, so I figured I’d:
1. Import the csv into Clients, while creating a new field “Dates to Process” to capture the multiple appointment dates
2. Use a script to loop through “Dates to Process” and create the appropriate records in Appointments
For step 2, I’m pretty sure I can loop through the “Dates to Process”, but I don’t know how to apply each date as a new record in “Appointments” that’s associated with that client in the parent Clients form. I see that in the script editor, I can tap on one-to-many icon next to Appointments, and get its ID, but after that, I’m at a loss.
Any help would be appreciated!
Hi Paul,
You can use the var newRecord = record.addNewRecordToField(field_id);
function to add a new record to a Link to Form field (or a Table field).
You’ll get a record object back which you can then set your values on.
Then save the form and everything will be saved.
Oh, and just to clarify, in the above example, the field_id
would be the ID of your Link to Form field and record
is the parent record. newRecord
is the child record.
Worked like a charm. Thanks, Brendan!