May 23, 200619 yr I'd like to create a script that creates a new related record in a different layout. Is there a way to do this without using a portal? I tried creating a script that copy/pasted the related field, however I saw that this is not a good idea because it pollutes the user's clipboard. I also had trouble getting this to work because my script kept selecting-all, instead of just the contents of the field in question. Am I missing something? Any advice would be really appreciated.
May 23, 200619 yr Try using the Set Field[] script step to set one of the related fields. The related field need not be on the current layout.
May 23, 200619 yr I often use the Set Field approach but there are a couple of drawbacks. First, creating related records this way can be slow. With one or a couple of related records, you want notice but watch out if you are creating hundreds in a looping script. Secondly, you have to jump through some hoops if you want to create a related record for a parent that currently has children. I often use the following approach: Go to Layout ["ChildLayout" (CHILDTABLE)] New Record/Request Set Field [ForeignKey; Get(ScriptParameter)] Go to Layout [original layout] Don't forget to assign the options script parameter to the button that runs this script so you can pass the primary key from the parent record to the script. Each technique has it's advantages and disadvantages. I've listed some of the disadvantages of Set Field but it does have the advantage of not requiring a layout. What if you decide to delete this layout? Well, the script parameter method won't work any longer because it is dependant on this layout. I like to keep layouts and scripts independent of each other whenever possible but not at the expense of speed or complexity. My suggestion is to learn both approaches so you can use each one at the right time. I even have an example file showing the Set Field, Script Parameter approach as well as an additional approach. http://www.filemakerpros.com/NEWROW.zip
Create an account or sign in to comment