- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2020 07:19 AM
Hello Community,
I'm working on a project that includes the following requirements:
- Create Service Catalog Item to request for a PC Refresh.
- Use the 'Create Request' UI Action functionality to create this request from an Incident.
- When clicking on Create Request, the UI Action should do the following:
- In the incident, add note to Additional Comments stating that the incident was converted to a request.
- Redirect to the Catalog Item and auto-populate the variables on the request.
The fields are auto-populate and redirects to the Catalog Item as required, however the fields continue to stay populated instead of clearing the values once the Catalog Item request is submitted. Any assistance with my scripting would be much appreciated.
Catalog Client Script:
function onLoad() {
var inc = g_user.getClientData('related_incident');
g_form.setValue('related_incident', inc);
var req = g_user.getClientData('requested_for');
g_form.setValue('requested_for', req);
var mgr = g_user.getClientData('manager');
g_form.setValue('manager', mgr);
var loc = g_user.getClientData('employee_location');
g_form.setValue('employee_location', loc);
var com = g_user.getClientData('reason_computer_needed');
g_form.setValue('reason_computer_needed', com);
var dsk = g_user.getClientData('desk_number');
g_form.setValue('desk_number', dsk);
var add = g_user.getClientData('additional_details');
g_form.setValue('additional_details', add);
}
UI Action:
var ses = gs.getSession();
ses.putClientData('related_incident', current.number);
ses.putClientData('requested_for', current.caller_id.sys_id.toString());
ses.putClientData('manager', current.caller_id.manager.sys_id.toString());
ses.putClientData('employee_location', current.location);
ses.putClientData('desk_number', current.caller_id.u_desk_area);
ses.putClientData('reason_computer_needed', 'PC Refresh/Upgrade');
ses.putClientData('additional_details', 'Converted to Computer Request from Incident Number: ' + current.number + '\n\n' + 'Incident Description: ' + '\n' + current.description);
current.comments = 'Incident converted to request for fulfillment. '; //Script doesn't populate Additional Comments in Incident
gs.setRedirect('com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=51e2db16dbba1810a4c02d89139619d5');
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2020 05:07 PM
Hi Keimo
You can include below lines before gs.setRedirect in UI action
current.incident_state = '6';
current.close_code = 'Solved (Permanently)';
current.close_notes = 'Incident converted to request for fulfillment';
current.update();
I hope this answers your question.
- Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2020 10:51 AM
I tried clearing the values onSubmit and had no luck. Here's my script:
function onSubmit() {
function clearClientData() {
var inc = g_user.getClientData('related_incident');
g_user.clearClientData('related_incident');
var req = g_user.getClientData('requested_for');
g_user.clearClientData('requested_for');
var mgr = g_user.getClientData('manager');
g_user.clearClientData('manager');
var loc = g_user.getClientData('employee_location');
g_user.clearClientData('employee_location');
var com = g_user.getClientData('reason_computer_needed');
g_user.clearClientData('reason_computer_needed');
var dsk = g_user.getClientData('desk_number');
g_user.clearClientData('desk_number');
var add = g_user.getClientData('additional_details');
g_user.clearClientData('additional_details');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2020 03:42 PM
I got it to work by writing a Script Include & Catalog Client Script GlideAjax call.
I'm still having issues with the following requirements once the user is redirected to the Catalog Item after clicking the UI Action:
- Set Incident State to 'Resolved'
- Set Incident Resolution Code to 'Solved (Permanently)'
- Set Incident Resolution Notes to 'Incident converted to request for fulfillment'

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2020 05:07 PM
Hi Keimo
You can include below lines before gs.setRedirect in UI action
current.incident_state = '6';
current.close_code = 'Solved (Permanently)';
current.close_notes = 'Incident converted to request for fulfillment';
current.update();
I hope this answers your question.
- Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2020 05:59 PM
Hi Pradeep,
This worked perfectly...thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2020 06:02 PM
You are very welcome Keimo.