Autopopulate variable value using Ui Action

abhisek
Tera Contributor

I am working on a requirement. Using UI Action creating a request from an Incident. Once we click on the UI Action a request will be created and incident will be cancelled. This portion is working.

There are 3 variables on the catalog item for example abc, def and xyz. Catlog item is in global application scope and ui action is in different application scope.

abc should be auto populated as per the incident short description, def should be auto populated as per the incident description and xyz should be auto populated as per the incident urgency. This portion is not working. Variables are not even populating.

Below is the script I have written:

 

(function executeRule(current, previous /*null when async*/) {
    try {
       
        var requestGr = new GlideRecord('sc_request');
        requestGr.initialize();
         requestGr.requested_for = current.caller_id;
         var requestID = requestGr.insert();
 
        var itemGr = new GlideRecord('sc_req_item');
        itemGr.initialize();
        itemGr.request = requestID;
        itemGr.cat_item = 'sysid of the catalog item';
        itemGr.requested_for = current.caller_id;
        var itemID = itemGr.insert();

        // Update the RITM with the request summary, description, and urgency
        itemGr.variables.abc= current.short_description;
        itemGr.variables.def= current.description;
        itemGr.variables.xyz= current.urgency;
        itemGr.update();

       
Can anyone please help me out, it is urgent.
6 REPLIES 6

@abhisek  

UI action is in which scope?

CartJS should work fine in both global + scoped app

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

Hi@Ankur Bawiskar 

UI action is in 'service operation workspace' scope and table is 'incident'.