Need to Change Stage on RITM after Rejected

jstocton
Kilo Expert

I failed to set the "STAGE" value via the workflow on Rejection.  I fixed the workflow so that the Stage is set appropriately if the RITM is Rejected.  NOW I NEED TO GO BACK TO THE RITMs that the workflows have ended and change the Stage to something more appropriate than Waiting for Approval.  The data and reporting is way off and we need to change them

I found a script from the community and have attempted to use in my DEV instance.  It worked once for one record but it does not work for any other records.  Can someone tell me why this script is not functioning?  Running it in:  Scripts-Backgroud

 

//For saftey target single record

//In () put the sys_id of the RITM that needs to be changed

var id = '(0314fdb313e01b0094003482e144b088)';
var item = new GlideRecord('sc_req_item');
if (item.get(id)) {
item.stage = 'Request Cancelled';
item.setWorkflow(false); //Don't fire off any workflow generated emails
item.update();
}

 

Thanks for any assistance provided.

1 ACCEPTED SOLUTION

Yes, we need to have the id in quotes, i was just talking about to remove the braces and not the quotes. 🙂 If "Request Cancelled" is the value then script with quotes will work. 

View solution in original post

3 REPLIES 3

Shishir Srivast
Mega Sage

Please remove the braces from id and then try.

 

var id = '0314fdb313e01b0094003482e144b088';
var item = new GlideRecord('sc_req_item');
if (item.get(id)) {
item.stage = 'Request Cancelled'; //Please pass the value here instead of label.
item.setWorkflow(false); //Don't fire off any workflow generated emails
item.update();
}

Put it in like this and got a Java Compiler Exception.  Put the single quotes back in and the expected results were achieved.  By the way, whoever setup the Stage: Request Cancelled has the label and the value with the UpperCase.  So the script DOES have the value.  It just looks funny because it shouldn't be that way.

 

At any rate.  The original script appears to be functioning now...   go-figure.

 

var id = 1105681913681b00508870146144b0e0;
var item = new GlideRecord('sc_req_item');
if (item.get(id)) {
item.stage = 'Request Cancelled'; //Please pass the value here instead of label.
item.setWorkflow(false); //Don't fire off any workflow generated emails
item.update();
}

Yes, we need to have the id in quotes, i was just talking about to remove the braces and not the quotes. 🙂 If "Request Cancelled" is the value then script with quotes will work.