How to trigger Service Request using Incident Close code | close_code

roshan_shetty10
Tera Contributor

After selecting Closure Code there's one more field Closure Issue type | u_issue_type_by_category (reference field)

after selecting particular option , we need to trigger a particular Catalog service request

1 ACCEPTED SOLUTION

Sujatha V M
Kilo Patron
Kilo Patron

@roshan_shetty10  You may try the below steps to achieve it. 

 

1. Create an "After" update business rule. 

 

SujathaVM_0-1733679508634.png

 

2. In Advanced section, add the below script to achieve creation of a request based on the resolution code. 

 

(function executeRule(current, previous /*null when async*/) {

    var conversionMessage = '';
    var sysidOfItem = '039c516237b1300054b6a3549dbe5dfc'; //For e.g Access Catalog Item 
    var cartId = GlideGuid.generate(null);
    var cart = new global.Cart(cartId);
    var item = cart.addItem(sysidOfItem);
    var assignmentGrp = current.getDisplayValue('assignment_group').toLowerCase();
    cart.setVariable(item, 'requested_for', current.caller_id);
    cart.setVariable(item, 'requested_by', current.opened_by);
    cart.setVariable(item, 'catalog_item', '039c516237b1300054b6a3549dbe5dfc');
    //Set for other variables similarly
    var req_num = cart.placeOrder();
    conversionMessage += 'Request ' + reqItem.number + ' created.<br />';
    setGroup(req_num.sys_id);
  
function setGroup(reqID) {
    var assignmentGroup = current.assignment_group;
    var assignedTo = current.assigned_to;
    var reqItem = new GlideRecord('sc_req_item');
    reqItem.addQuery('request', reqID);
    reqItem.query();
    if (reqItem.next()) {
        reqItem.parent = current.sys_id;
		reqItem.comments = "Incident : "+ current.number +" has been converted as 'Request': " + reqItem.number;
		reqItem.update();
    }    
}
})(current, previous);

 

3. Now on closure/resolution of the incident, a request is created. 

 

SujathaVM_1-1733679909066.png

 

 

Please mark this as helpful and accept it as a solution if this resolves your query.
Sujatha V.M.

View solution in original post

3 REPLIES 3

Sujatha V M
Kilo Patron
Kilo Patron

@roshan_shetty10  You may try the below steps to achieve it. 

 

1. Create an "After" update business rule. 

 

SujathaVM_0-1733679508634.png

 

2. In Advanced section, add the below script to achieve creation of a request based on the resolution code. 

 

(function executeRule(current, previous /*null when async*/) {

    var conversionMessage = '';
    var sysidOfItem = '039c516237b1300054b6a3549dbe5dfc'; //For e.g Access Catalog Item 
    var cartId = GlideGuid.generate(null);
    var cart = new global.Cart(cartId);
    var item = cart.addItem(sysidOfItem);
    var assignmentGrp = current.getDisplayValue('assignment_group').toLowerCase();
    cart.setVariable(item, 'requested_for', current.caller_id);
    cart.setVariable(item, 'requested_by', current.opened_by);
    cart.setVariable(item, 'catalog_item', '039c516237b1300054b6a3549dbe5dfc');
    //Set for other variables similarly
    var req_num = cart.placeOrder();
    conversionMessage += 'Request ' + reqItem.number + ' created.<br />';
    setGroup(req_num.sys_id);
  
function setGroup(reqID) {
    var assignmentGroup = current.assignment_group;
    var assignedTo = current.assigned_to;
    var reqItem = new GlideRecord('sc_req_item');
    reqItem.addQuery('request', reqID);
    reqItem.query();
    if (reqItem.next()) {
        reqItem.parent = current.sys_id;
		reqItem.comments = "Incident : "+ current.number +" has been converted as 'Request': " + reqItem.number;
		reqItem.update();
    }    
}
})(current, previous);

 

3. Now on closure/resolution of the incident, a request is created. 

 

SujathaVM_1-1733679909066.png

 

 

Please mark this as helpful and accept it as a solution if this resolves your query.
Sujatha V.M.

I commented this : conversionMessage += 'Request ' + reqItem.number + ' created.<br />';
after that it's working perfectly , Thank you 

Community Alums
Not applicable

You can do this in flow designer when the particular option selected would be your trigger against the table in flow and then follow it up with an action to submit the service request