Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch › Forums › Using Tap Forms 5 › Set default value of new record to parent value
- This topic has 3 replies, 3 voices, and was last updated 9 months, 3 weeks ago by
JScottA.
-
AuthorPosts
-
January 8, 2025 at 7:06 PM #51482
Sarah YoungParticipantIs there a simple way, on creating a new child record, to set the value of a child field to a value in the parent record? I do not want these fields synced, I just want to set a default starting value on the child record.
If not, it’s been nearly 10 years since I’ve written JavaScript (and I hated it then), so could use a pointer in the right direction for knowing Tapform specific syntax/object names.
Thanks!January 9, 2025 at 1:20 AM #51484
BrendanKeymasterWhat kind of relationship do you have between the parent and child? If it’s a Join relationship, then when you add a Child Record, Tap Forms should automatically set the value from the parent to the child’s matching field value.
But if that’s not what you want, then you would need to use a script to create a child record, add it to the parent’s Link to Form field and copy the value from the parent to the child field.
You would use the
addNewRecordToField()function for that:var parentRecordValue = record.getFieldValue(parent_field_id); var newChildRecord = record.addNewRecordToField(link_to_form_field_id); newChildRecord.setFieldValue(child_field_id, parentRecordValue);Something like that should work.
January 9, 2025 at 6:43 PM #51491
Sarah YoungParticipantThat is very helpful, thank you Brendan! It’s a 1:M relationship, so will need a script.
I’ve also now found the javascript documentation which I think/hope will get me the rest of the way there. (somehow I missed this yesterday when I was looking for info, so apologies for asking a question that is probably in those docs!)
January 10, 2025 at 7:54 AM #51492
JScottAParticipantIf it helps, there is an unofficial custom GPT on the ChatGPT store called, Tap Forms 5 Assistant that is tuned specifically for scripts in TF5. Here is the link:
I hope that it helps you. However, Brendan is the final authority on all things TF5.
-
AuthorPosts
You must be logged in to reply to this topic.