Can I set a g_scratchpad variable on a catalog client script for later use?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2019 10:20 AM
I have an onLoad client script that looks like... (onchange of remit_to variable)
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_scratchpad.holder = newValue;
}
I can't alert g_scratchpad.holder though. Is g_scratchpad not meant to be used this way?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2019 10:16 PM
Try "setPreference()" then:
Then its set serverside and not client side and should be available as long as the user is logged in

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2019 05:34 AM
I can able to see the alert when Incident form load
function onLoad() {
//Type appropriate comment here, and begin script below
alert("Working OK"+g_scratchpad.priority);
g_form.setValue('u_string_4',g_scratchpad.priority);
g_scratchpad.holder = "newValue";
alert(g_scratchpad.holder);
//g_scratchpad.someName = "someValue";
//g_scratchpad.anotherName = "anotherValue";
}
=======================
On Display Business Rules we can set the g_scratchpad
Above scenario is working fine for me however you can create the new form field where you would like to (set or save the value).
Suppose if you create any field on the Incident form and apply globally however that will be visible for all incidents.
What exactly your requirement.
Please mark helpful or mark as answer if working for you.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 05:57 AM
Hi, not sure if this is still an issue but thought I'd chuck it here just in case it helps someone else.
Frustratingly, g_scratchpad only seems to work in the portal UI and not in desktop.
However, I have managed to use window.attribute_name in the desktop UI which does allow you to share values between multiple scripts and works exactly the same as g_scratchpad (although I have no idea whether or not this would be considered best practice).
Hope this helps 🙂