Passing session data from Interaction to Catalog item but Clear Session Data is not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2022 07:22 AM
I have created a solution to pass session data from an Interaction in Workspace to a Catalog Item opened in new tab. However the Clear Session Data is not working as expected. It is holding onto the previous interaction's data when you use the UI Action on the next interaction. Oddly, you can refresh the browser tab and the new data loads. Would like someone to review my scripts to see where I need to make changes.
__________________________________________________________
UI Action: Create Request
Workspace Client Script:
function onClick(g_form) {
//Complete IMS
var type = g_form.getValue('type');
var reason = g_form.getValue('u_reason');
if (type == 'data') {
g_form.setValue('state', 'closed_complete');
g_form.setValue('u_reason', 'Assistance');
g_form.setValue('work_notes', 'New request for development has been submitted.');
g_form.setValue('assigned_to', g_user.userID);
}
var result = g_form.submit('sysverb_ws_save');
if (!result) { // failed form submission
return;
}
var params = {};
params.sysparm_parent_table = "interaction";
params.sysparm_sysid = g_form.getUniqueValue();
//Set Session data
var User = g_form.getValue('opened_for');
var imssysid = g_form.getUniqueValue();
var RefIMS = imssysid;
var shortDesc = g_form.getValue('short_description');
var Desc = g_form.getValue('u_description');
var request = new GlideAjax('AgentWorkspaceUtilsGA');
request.addParam('sysparm_name', 'setData');
request.addParam('opened_for', User);
request.addParam('u_description', Desc);
request.addParam('short_description', shortDesc);
request.addParam('imssyid', RefIMS);
request.getXMLAnswer(function(answer) {
onSubmitAfterSessionPut(params);
});
// Current context (anonymous method executed by Agent Workspace)
openUrl("/com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=2fcd49c81bc11d109d23ea0dad4bcb2b");
}
function openUrl(url) {
// Current context the window of Agent Workspace
top.window.open(url, '_blank');
}
______________________________________________________________________________
Script Include: AgentWorkspaceUtilsGA
var AgentWorkspaceUtilsGA = Class.create();
AgentWorkspaceUtilsGA.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
setData: function() {
var User = this.getParameter('opened_for');
gs.log(User);
//Add user sysid in session
gs.getSession().putClientData('opened_for', User);
var RefIMS = this.getParameter('imssyid');
gs.log(RefIMS);
//Add ims sysid in session
gs.getSession().putClientData('imssyid', RefIMS);
var shortDesc = this.getParameter('short_description');
gs.log(shortDesc);
//Add short description in session
gs.getSession().putClientData('short_description', shortDesc);
var Desc = this.getParameter('u_description');
gs.log(Desc);
//Add description in session
gs.getSession().putClientData('u_description', Desc);
},
clearData: function() {
//Clear data in session
var session = gs.getSession();
session.clearClientData('opened_for');
session.clearClientData('imssyid');
session.clearClientData('short_description');
session.clearClientData('u_description');
return 'clientData Cleared';
},
type: 'AgentWorkspaceUtilsGA'
});
_________________________________________________________________
Catalog Client Script: Set Variables from Interaction
Type: OnLoad
function onLoad() {
var opened_for = g_user.getClientData('opened_for');
if (opened_for != '') {
g_form.setValue('requested_for', opened_for);
}
var imssyid = g_user.getClientData('imssyid');
if (imssyid != '') {
g_form.setValue('ref_ims', imssyid);
}
var short_description = g_user.getClientData('short_description');
if (short_description != '') {
g_form.setValue('short_description', short_description);
}
var u_description = g_user.getClientData('u_description');
if (u_description != '') {
g_form.setValue('ims_details', u_description);
}
}
//Clear client session data
var clearSession = new GlideAjax('AgentWorkspaceUtilsGA');
clearSession.addParam('sysparm_name', 'clearData');
clearSession.addParam('opened_for', g_form.getValue('requested_for'));
clearSession.addParam('imssysid', g_form.getValue('ref_ims'));
clearSession.addParam('short_description', g_form.getValue('short_description'));
clearSession.addParam('u_description', g_form.getValue('ims_details'));
clearSession.getXMLAnswer(function(answer) {});
- Labels:
-
Agent Workspace
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2024 02:03 AM
Hi @Melissa Bennett , encountered this issue as well. were you able to find the fix?