UI action Cancel button only cancelling the ritm not the request as well

Joshua Comeau
Kilo Sage

Need to know why the cancel button I created is not cancelling the request as well:

JoshuaComeau_0-1688562729675.png

 

1 ACCEPTED SOLUTION

Yes like this, I added the script too.

-Anurag

View solution in original post

10 REPLIES 10

Anurag Tripathi
Mega Patron
Mega Patron

HI,

You cannot dotwalk and update the record, dot walk is for reading only. To update you need to GlideRecord to the target record

Something like below

var req = new GlideRecord('sc_request');
req.addQuery('sys_id', current.request);
req.query();
if(req.next())
{
req.stage = 'closed_incomplete';
req.state = 4;
req.update();
}
-Anurag

Ankur Bawiskar
Tera Patron
Tera Patron

@Joshua Comeau 

do you have any BR on RITM table which cancels the REQ once RITM is cancelled?

if not then in the UI action script itself add code to Cancel the REQ

var req = current.request.getRefRecord();

req.state = 4; // give correct choice value for cancel on REQ table

req.update();

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Samaksh Wani
Giga Sage
Giga Sage

Hi Joshua,

 

CRUD functions need GlideRecord to get Execute you need to use the Script :-

 

 

var request = new GlideRecord('sc_request');
var currentReq = current.request;
request.addQuery('sys_id', currentReq);
request.query();
if(request.next())
{
request.request_state = 'Closed Cancelled';
request.stage = 'Closed Incomplete';
request.state = 4;
request.update();
}

 

 

Mark my Solution as Accept and Thumbs up, If you find Helpful.

 

Regards,

Samaksh

so it cancelled the request but not the ritm how to get it to do both?