Trying to Change RITM Stage value based on Catalog Task State

Raghesh
Giga Expert

Hi,

I have a requirement say for example when Catalog Task - State moved to "Pending" then RITM - Stage should be "Pending". Based on RITM "Pending" Stage I wanted to pause the Resolution SLA for this Catalog item.

I tried a Business Rule to change the Stage however it is not working as expected. Please find the script below I am using in Business rule.

find_real_file.png

 

 

Script under Advanced tab:

(function executeRule(current, previous /*null when async*/) {

// Add your code here
gs.addInfoMessage("current.state"+current.state);
var gr = current.request_item.getRefRecord();
if(current.state == -5){
gr.stage ='Pending';
}
else{
gr.stage ="fulfillment";
}
gr.update();
gs.addInfoMessage("the set stage is "+gr.stage);

})(current, previous);

 

What I am doing wrong here, it would be great if anyone can assist.

 

regards,

Raghesh

4 REPLIES 4

VaranAwesomenow
Mega Sage

//Did you want to set stage or state ?

//State can be set via BR, if its stage its a good practice that it comes from either flow or workflow.

(function executeRule(current, previous /*null when async*/) {

// Add your code here
gs.addInfoMessage("current.state"+current.state);

var gr = new GlideRecord('sc_req_item');

gr.get(current.request_item.sys_id);
//var gr = current.request_item.getRefRecord();
if(current.state == -5){
gr.stage ='Pending';
}
else{
gr.stage ="fulfillment";
}
gr.update();
gs.addInfoMessage("the set stage is "+gr.stage);

})(current, previous);

I want to set the Stage of RITM to Pending. I am using workflow to manage the lifecycle of this Catalog Item.

 

regards,

Raghesh

Brian Lancaster
Tera Sage

Do you have a stage of pending? The out of the box stages do not include pending. 

Hi Brian,

Yes I have a Stage as Pending in RITM. Please refer the screen shot below.

 

find_real_file.png