Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch › Forums › Using Tap Forms Pro › Changing Parent Record via Script?
- This topic has 4 replies, 3 voices, and was last updated 2 days, 5 hours ago by
Shane.
-
AuthorPosts
-
November 23, 2025 at 9:25 AM #53279
ShaneParticipantHey all, so far I’m excited about the power of scripting in TapForms and am trying to put it to good use.
I’m trying to create a template system where I can copy/move placeholder records to a new parent record. Normally to assign a child record to parent record you would click the “Select and link existing records” object/ button which would bring up the possible parent records for reassignment (see screenshot). I’m wondering if this could be done through scripting.
In this example I have a Clients parent form linked to a child Projects form.
You can seem to access the parent record by doing the following (see second screenshot):
function Reassign() { var clients = record.getFieldValue('fld-25ab19edf2014cc0952446ed09975851'); console.log(clients); } Reassign();Console shows a record object:
2025-11-23, 8:02:35 AM / Projects / Reassign
[object CDRecord]So can we somehow code a different parent record for the child record somehow?
Thanks.
Attachments:
You must be logged in to view attached files.November 23, 2025 at 9:37 AM #53282
Daniel LeuParticipantI agree, the scripting feature is very powerful. Without it, I wouldn’t use TFP.
You can add a linked record using
var newRecord = record.addNewRecordToField(field_id);and to remove an existing record there’srecord.removeRecordFromField(childRecord, field_id');. Here’s the link to the documentation https://www.tapforms.com/help-mac/pro/en/topic/javascript-api.Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricksNovember 23, 2025 at 10:11 AM #53284
ShaneParticipantThanks for the reply.
I did read that documentation, but isn’t that used to add a child record to a parent record? I was referring to changing the parent record to the child record.
I guess if I wanted to copy template children to a new parent I could do it that way. I could use a script to essentially copy the child record info from a template parent record and recreate those children records under the new project name. However, I am still curious if you could use a script to change the parent record of a child record. :)
-
This reply was modified 5 days, 14 hours ago by
Shane.
November 24, 2025 at 2:29 PM #53294
BrendanKeymasterThere’s also the
record.addRecordToField(someRecord, field_id);function which lets you add an existing record to a Link to Form field. So it doesn’t have to be a new one. And if it’s a One-To-Many, then that essentially moves the record since you can’t have a child record belong to more than one parent with that link type.November 26, 2025 at 6:46 PM #53312
ShaneParticipantThanks Brendan, I’ll give that a try.
-
This reply was modified 5 days, 14 hours ago by
-
AuthorPosts
You must be logged in to reply to this topic.