Jump to content

Creating a related record without using a portal

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

Recommended Posts

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.

Link to comment
Share on other sites

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.


Link to comment
Share on other sites

This topic is 5678 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.