- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2018 06:40 PM
I'm looking for a simple way to pass a variable between forms so that the variable value is set onSubmit of the first form and is read onLoad of the second form. Totally new to ServiceNow and javaScripting so, after reading dozens of posts and following dozens of suggested links in those posts, I'm still coming up empty handed. In VB, you'd simply declare a global variable and call it when needed. Not sure what the counterpart is in JavaScript. Any help you can provide would be appreciated -- especially if you have a code snippet that you've used to do this in the past.
Thanks in advance for your help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2018 06:02 AM
Ah I see. Then I would say the UI Action is a good bet.
If you just want to create a record populating the one field with the one field from the current record is perform a glide record script before the current.update().
Something like this:
var pvg_patient = new GlideRecord('pvg_patients'); // of course replace with the real name of the table
pvg_patient.client_number = current.client_number;
pvg_patient.insert();
current.update();
action.setRedirectUrl(pvg_patient); //redirects them to the "PVG Patients" form
action.setReturnUrl(current); //puts the previous form in this case 'PVG Client' form on the stack
And that should do it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2018 08:05 AM
If there isn't anything more to your script, is there a reason that "Client" needs to be checked?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2018 08:10 AM
There's nothing more to the script. I checked it because I was following another example from a thread somewhere that has the box checked. Also, when I uncheck the client box, the code runs, does nothing (doesn't create the patient record), and returns me to the client list (not the client form).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2018 07:19 PM
Try using scratchpad in display BR of the table.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2018 07:29 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2018 05:15 AM
Great thread. Looks like exactly what I'm trying to do. Am working through it now to translate it to my needs. Will let you know if it worked. Thanks for the pointer!