Article on Agent Workspace : Convert Incident to Request using UI action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2024 12:42 AM
Problem Statement : Convert Incident to Request using UI action and cascade the values to the fields mapped.
Steps Involved:
1. Create an UI action named as "Convert to Request" on the incident table as below,
2. Navigate to the "Workspace" tab on the UI action page and set the "Workspace Form Button" as "True" and below in Workspace Client Script,
function onClick(g_form) {
var params = {};
var incident_number = g_form.getUniqueValue('number');
var callerID = g_form.getValue('caller_id');
var shortDesc = g_form.getValue('short_description');
var req = new GlideAjax('ConvertIncidentToRequestUtils');
req.addParam('sysparm_name', 'setFormFields');
req.addParam('sysparm_incident', incident_number);
req.addParam('sysparm_caller_id', callerID);
req.addParam('sysparm_short_desc', shortDesc);
req.getXMLAnswer(function(answer){
routetocatalogItem(params);
});
}
function routetocatalogItem(params) {
g_service_catalog.openCatalogItem('sc_cat_item', '<sys id of the catalog item>', params);
}
Script include:
var ConvertIncidentToRequestUtils = Class.create();
ConvertIncidentToRequestUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
setFormFields: function() {
var incident_number = this.getParameter('sysparm_incident');
var callerID = this.getParameter('sysparm_caller_id');
var shortdescription = this.getParameter('sysparm_short_desc');
gs.getSession().putClientData('incidentID', incident_number);
gs.getSession().putClientData('requestedFor', callerID);
gs.getSession().putClientData('shortdescription', shortdescription);
},
clearFormFields: function() {
//Clear session
gs.getSession().clearClientData('incidentID');
gs.getSession().clearClientData('requestedFor');
gs.getSession().clearClientData('shortdescription');
},
type: 'ConvertIncidentToRequestUtils'
});
3. Create a catalog item and an onLoad catalog client script to cascade the values from "Incident" to the form variables.
function onLoad() {
var incidentNumber = g_user.getClientData('incidentID');
var requested_for = g_user.getClientData('requestedFor');
var shortdesc = g_user.getClientData('shortdescription');
if (requested_for != '' && incidentNumber != '') {
g_form.setValue('requested_for', requested_for);
g_form.setValue('incident_number', incidentNumber);
if(shortdesc != ''){
g_form.setValue('short_description', shortdesc);
}
}
//Clear client session data
var clearSesion = new GlideAjax('ConvertIncidentToRequestUtils');
clearSesion.addParam('sysparm_name', 'clearFormFields');
clearSesion.getXMLAnswer(function(answer) {});
}
Results :
On click of the "Convert to Request" button, it routes to the catalog item and cascades the incident form values to the catalog item variables.
Please mark this as helpful and accept it as a solution if this resolves your query.
Thanks,
Sujatha V.M.
Sujatha V.M.
- 301 Views