- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2020 06:59 AM
Hello... I have UI action that save session data of number, short description and description of incident that i want to add to request variables
UI Action:
var session = gs.getSession();
session.putClientData('number', current.sys_id);
session.putClientData('short_description', current.short_description);
session.putClientData('description', current.description);
url="sp?id=sc_cat_item&sys_id=f959c1fa2f5a4010151e877cf699b6a9&sysparm_category=d258b953c611227a0146101fb1be7c31";
action.setRedirectURL(url);
And i have catalog client script in item:
function onLoad() {
//Type appropriate comment here, and begin script below
if (null != g_user.getClientData('number')) {
var num = g_user.getClientData('number');
g_form.setValue('incidentnum', g_user.getClientData('number'));
var sd = g_user.getClientData('short_description');
g_form.setValue('subjek', num);
var desc = g_user.getClientData('description');
g_form.setValue('deskripsi', desc);
}
}
Its work, but how can i clear data session after i click the UI Action? I need to clear data after form request is load so, when i open the same form, the data will be empty. Please help. Thank you
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2020 12:31 PM
Ok, the only way I can seem to get this to work in a Catalog Item is to do it via a GlideAjax call (basically just shifting this from client-side to server side). I made a quick script include that looks like this:
name: clientData
client callable: checked.
var clientData = Class.create();
clientData.prototype = Object.extendsObject(AbstractAjaxProcessor, {
type: 'clientData',
clearData: function() {
var session = gs.getSession();
session.clearClientData('number');
session.clearClientData('short_description');
session.clearClientData('description');
return 'clientData Cleared';
},
});
And then in a client script call:
var ga = new GlideAjax('clientData');
ga.addParam('sysparm_name', 'clearData');
ga.addParam('sysparm_id', g_form.getValue('ref_server_name'));
ga.getXML(procResponse);
function procResponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
//indicate the response in the console
jslog(answer);
}
Michael D. Jones
Proud member of the GlideFast Consulting Team!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2020 07:59 AM
You can use clearClientData()
So, after you set the values on form load, add lines like this to your script:
g_user.clearClientData('number');
g_user.clearClientData('short_description');
g_user.clearClientData('description');
If this was helpful or correct, please be kind and click appropriately!
Michael D. Jones
Proud member of the GlideFast Consulting Team!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2020 09:11 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2020 11:34 AM
Hmm sorry about that. Try setting the values to null once you pull them instead.
g_user.setClientData('number', null);
g_user.setClientData('short_description', null);
g_user.setClientData('description', null);
That seems to work in my PDI.
If this was helpful or correct, please be kind and click appropriately.
Michael D. Jones
Proud member of the GlideFast Consulting Team!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2020 11:51 AM
Nope, sorry, doesn't seem to work with a catalog item.
Works like a charm on a table form, but seems to do nothing in the catalog - not even throw an error.
Michael D. Jones
Proud member of the GlideFast Consulting Team!