Here is a script step if you haven’t used yet then you really should. I’m going to give an entry level introduction to it in this post but watch for more posts expanding on how it can be used further.

For this demo we have a Account table and Contacts table. While there are a number of ways to create the contact record, we’re using the PSoS because it’s a simple record to create and will give you a base of where to start. I will use 2 scripts to create the record but it can be done in one.

The first script will be called “New Contact” and the other I’ll call “PSoS – New Contact”. Adding the “PSoS” just lets me know this script will run on the server. I’ve added the New Contact button on my layout as you can see in the image below.

 

layout_before_running

 

The image below shows the New Contact script. You can see that I am setting a variable for the Account key that I am passing in the Perform Script On Server script step. I am also choosing the option Wait for completion which is a Script Step Option ( image also below ) so I get a result back from the server before the rest of my script finishes.

 

new_contact
script_step_options

 

Now that I have run the script on the server you’ll notice I have added an error capture with Get ( ScriptResult ), this will be passed back to me from the server as you see in the below image where it actually is creating my record.

 

psos_new_contact

 

One thing to note is the server doesn’t know what you want so you need to make sure it goes to the correct layout and sets the correct fields. You can see I go to my CON ( Contacts ) layout, create my record and set the account key before committing and exiting the script. The Exit Script step is where I have added the Get ( LastError ) in the event something went wrong I will know on the way back. This could also be used to pass data as I will show in the next post.

 

new_contact

 

If we return back to the original script in the above image you’ll notice if there is an error I’ll show a dialog box displaying the error and Exit the script. If there’s no error we are going to the portal that I have named portal.contact then to the last portal row and finally selecting the first name field which I gave an object name of portal.contact.first.name. The image below shows the result when it all works together.

 

after_script_runs

 

Watch for more advanced ways to use PSoS coming soon. Thanks for reading and have a great week!

– James

James Scarpetta
The Scarpetta Group, Inc.
FileMaker 13/12 Certified Developer & FBA Trainer
james@scarpettagroup.com
Follow us on Twitter: @scarpettagroup

[info ]Like our blog posts? Sign up for our Mailing List on the bottom of this page! Have a “Time Saving Tip” of your own? Email info@scarpettagroup.com to share.[/info]