- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 06:12 AM
Need to know why the cancel button I created is not cancelling the request as well:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 07:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 06:16 AM
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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 06:17 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 06:33 AM - edited 07-05-2023 06:35 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 07:16 AM
so it cancelled the request but not the ritm how to get it to do both?