Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 6761 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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.

Posted

Try using the Set Field[] script step to set one of the related fields. The related field need not be on the current layout.

Posted

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

This topic is 6761 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.