It would help to see the actual script that you are using.
To post a script to the forum:
- You can upload a screen shot of your script by using the Upload an Image controls located just below Post a New Answer.
- You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here. (with this approach, you can get multiple script steps on the same line, please edit the pasted text by inserting some returns to separate those steps.)
- If You have FileMaker Advanced, you can generate a database design report and copy the script as text from there.
- If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format.
Thanks Phil. Here's the script. Two foreign keys are flipped, and two relation (employer becomes employee) types are flipped. RelationReciprocalexists is just a field I use for conditional formatting (when it's 'Yes' the button that runs this script is hidden):
- Set Field [ join_Contacts_Contacts::RelationReciprocalExists; "Yes" ]
- Set Variable [ $fkContactsID; Value:join_Contacts_Contacts::_fkContactsID ]
- Set Variable [ $fk_relations_ContactsID; Value:join_Contacts_Contacts::_fk_relations_ContactsID ]
- Set Variable [ $RelationRecip; Value:join_Contacts_Contacts::RelationReciprocalType ]
- Set Variable [ $Relation; Value:join_Contacts_Contacts::RelationType ]
- Duplicate Record/Request
- Set Field [ join_Contacts_Contacts::_fkContactsID; $fk_relations_ContactsID ]
- Set Field [ join_Contacts_Contacts::_fk_relations_ContactsID; $fkContactsID ]
- Set Field [ join_Contacts_Contacts::RelationType; $RelationRecip ]
- Set Field [ join_Contacts_Contacts::RelationReciprocalType; $Relation ]
- Commit Records/Requests [ No dialog ]
- Close Popover
Default tab order- script work. The record represented on the portal row (in join_contacts_contacts) is duplicated.
No tab order- the Contact record is duplicated.
I'm surprised that works with or without the tab order.
Any time that I've used Duplicate Record/Request, it's duplicated the current record in the layout's found set--not the current record in a portal row.
Just to be sure, I made a copy of a layout where I have several portals used for data entry and where they have "allow creation..." enabled.
I tried with both a plain button inside the portal row and with a button placed in the popover whose button is inside the portal row.
In both cases the script duplicated the layout's record--not the portals and this is what I would expect to happen.
Any time that I've needed to duplicate a portal record, I've used either a scripted find or Go to Related Records to bring that record up on a layout based on the portal's record and used duplicate record in that context to duplicate the portal record and not the layout's record.
That's it, thanks Phil. I introduced a go to related record step, and I'm reading your "The Complete Go To Related Record" post to try and get it right.