Incident to Create Request UI Action Functionality

keimo
Tera Contributor

Hello Community,

I'm working on a project that includes the following requirements:

  1. Create Service Catalog Item to request for a PC Refresh.
  2. Use the 'Create Request' UI Action functionality to create this request from an Incident.
  3. 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');

 

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

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

 

View solution in original post

21 REPLIES 21

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

the variables will be populated and will be present once RITM is submitted.

Can you explain exact issue?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

The variables are populated as required on the Catalog Item when you click on the 'Create Request' UI Action. The issue is that the values don't clear after the RITM is submitted. This can create confusion since the Catalog Item is also being used in the Order Guide and the request will be pre-populated with values from the previous submission.

Hi,

So consider you are taking them to a catalog item having those variables.

Now user will see the variables auto populated

User will submit the request and RITM will be generated.

Where are the values not cleared after RITM submission?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi,

None of the values are cleared on the Catalog Item request form view.