The CreatorCon Call for Content is officially open! Get started here.

Canceling a ServiceNow Request

mallikabhupathi
Tera Expert

Hi all,

If I want to cancel a ServiceNow request, as a requester I want to choose the Request state as "Closed Cancelled". When this is selected, I want the state on the RITM and the SCTask to change to Closed Skipped.

Can you let me know how this can be achieved?

 

Thanks,

Mallika

7 REPLIES 7

Dan H
Tera Guru

Hi,

Usually the requester is an external user or a user who shouldn't typically have the roles needed to update RITMs.

What is your requirement? Why do you want to do this. There may be a better solution

 

Here is a business rule to close RITM/SCTasks when the REQ request state is changed to closed cancelled.

Business rule:

find_real_file.png

 

Script:

 

(function executeRule(current, previous /*null when async*/) {
  var ritm = new GlideRecord('sc_req_item'); //find the RITM and close it
  ritm.addQuery('request', current.sys_id);
  ritm.query();
  if(ritm.next()) {
    ritm.state = 7;
    ritm.update();
  }

  var scTaskGR = new GlideRecord('sc_task'); //find all the SC Tasks and close them
  scTaskGR.addQuery('request_item.request', current.sys_id);
  scTaskGR.query();
  while (scTaskGR.next()) {
    scTaskGR.state = 7;
    scTaskGR.update();
  }
})(current, previous);

 

 

Please mark my answer as Correct/Helpful based on impact

Regards,

Dan H

Hi @Dan H,

 

Sometimes the user submits a request and after the task is created realize that the request is no longer required. 

Okay, no problem.

The business rule I have posted will fulfill your request.

Let me know if there is any issues, i'm happy to help.

 

Please mark my answer as Correct/Helpful based on impact

Regards,

Dan H

Hi @Dan H ,

 

I tried using the business rule you shared but it is changing the State on the RITM and the Task to Closed Incomplete.

 

Is this an OOB feature of ServiceNow?

 

Thanks,

Mallika