I can use the Copy Master detail records to copy a Record with its related child records.
And separately I can use the Master Details wizard to add child records from a different record (ie a template record)
What I want do to those copy the Parent record AND add child records from the template. (so child records are created but fields unpopulated while parent record is fully populated).
Thanks for any suggestions.
In two clicks it's easy. Just make a Copy Master detail button and when you make it, specify that the Child records are to always come from the same parent record. Then put the button on your Parent record but hide it once the parent has children.
Related question: When i add the detail records from the template I get a prompt that says "records" have been added and then I am put into the "display" view for the parent record. Any easy way to instead go to the "Edit View" of the parent record (so users can immediately edit the embedded report)
You will need to read the help text on the API for API_CopyMasterDetail
Here is an example
var text URLONE =URLRoot() & "db/" & Dbid() & "?a=API_CopyMasterDetail"
& "&apptoken=xxxxxx" if you are requiring app tokens.
& "&destrid=" & ToText([RecordID#])
& "&sourcerid=" & "insert the fixed record id of the source record here")
& "&relfids=208"; // the rel fids are the field ID's of the report link fields on the relationships that you want to have imported. They
can be comma separated, but it sounds like you just have 1 child table to be imported.
var text URLTWO = URLRoot() & "db/" & Dbid() & "?a=er&rid=" & totext([Record id#]); // the er will land you in edit mode.
& "&rdr=" & URLEncode($URLTWO)
I have not tested this, but it should work.
Issue apparently is that there is no FID available to copy for the current Record ID (since it has not been save yet). But is there a way to make saving the current record the initial step in the code?
There is a way to get Predict the Record ID, but if you are in a multi user environment, there is a risk. You could have Table that counts the max record ID of the Parent table. Add just Just 1 record with record id =1. Then on the Parent table where the button lives you have a reference formula field with a formula of 1 and then make a relationships and then Summary field of Max record ID#. Then look that up down to the Parent. So then you know the next record ID will be max plus 1.
But if the user is sitting on a record for any length of time, the URL is frozen in place. So other users could create more Parents and then the URL will not be fresh and not have the latest summary max of Record ID's that exist.