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

There is probably an OOTB business rule running when the Request state/RITM state/SC task state is changed to one of the states being set in the business rule.

You can look into disabling any follow on business rules by adding

setWorkFlow(false);

To the end of the business rule.

 

However, I wouldn't really recommend doing this as these OOTB business rules running on these tables are there for a reason.

Alternatively, you could find the business rule that is changing the RITM/SCTask to closed incomplete and change the value to 7. Like it is in my business rule.

From a best practice approach, it would be better to leave these as closed incomplete as this is technically what the state should be when the REQ state is closed cancelled.

 

Hope this helps.

 

dmathur09
Kilo Sage

Hi Mallika,

You need to create a after business rule on request table that would run when state is closed skipped.

In the advanced condition use the below code

var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request',current.sys_id);
ritm.query();
while(gr.next())
	{
			ritm.state = 7;
	}

var ritm = new GlideRecord('sc_task');
ritm.addQuery('request_item.request',current.sys_id);
ritm.query();
while(gr.next())
	{
			ritm.state = 7;
	}

Regards,

Deepankar Mathur

Fred Jean
Tera Expert

Hello, I have the same request form a client, but I'm not sure it would be right to let the user actually close the request/RITM, as it may involve tasks already done, that  might then need some rollback action.

May be that's the reason why there is nothing build in for that use case, and then the only option is for the user to send a comment asking to cancel; then the agent could take relevant actions.