I want to put into a field a value from a field in a related record. I’ve defined the relationship as a “join”, based on a different field in each form, and for present purposes it doesn’t matter to me which of the forms is the parent and which the chid. I’ve written a really basic script, where the target field is called “Test Field” and the field in the related record from which I want to get the info is called “Line Up”:
var test_field_id = ‘fld-49c13a65b1324a92941d51a895526d06’;
var line_up = record.getFieldValue(‘fld-ece13baf855a423cb121bfde1167f1b4’);
If you are pulling from a JOIN field, you need to get the records in that JOIN. JOIN is a many to many type so you will get multiple records back:
var joinRecords = record.getFieldValue('fld-nameofjoinfield');
This will return you a list of records that you need to iterate over. If you look in the snippet editor there is a “child records loop” snippet that should help you if you select the field you care about and then do something useful with it.
Depending on your use case, the result of last line of your script field will be used as the script field value. If you’re looking to pull values out then you can just leave a line with the variable in it that you want to show up in the field.