Client Script

ARAVIND22
Tera Contributor

@Ankur Bawiskar/friends,  Sir please help

 

I need to Update the State in RITM which is showing as  what ever the value is showing below I have to make it to closed complete - state. When the stage is complete

 

1- work in progress

2 - pending

3 - Open

 

PLEASE HELP VERIFY IMAGE ATTACHED AS WELL

 

 

2 ACCEPTED SOLUTIONS

praneeth7
Tera Guru

Hi Aravind,

This script will do the work. Just try to run it in Background-script

var item = new GlideRecord('sc_req_item');
item.addActiveQuery();
item.query();
while(item.next()){
       var label = item.getDisplayValue('stage');
       if(label == 'Completed'){
       var value = item.getValue('state');
       if(value == 1 || value== 2 || value == -5){
       item.setValue('state',3);
       gs.print(value);
       item.update();
}
}
}

Please mark my answer as helpful or solution if this helps you,

Thank you.

View solution in original post

Hi Aravind,

 

1, 2, & -5 refers to the backend value of the state choices. You can find the values under configure dictionary or show choice list by right clicking on the field label.

 

If you find my answer useful, please mark my  answer Helpful !! 

Thank you.

View solution in original post

7 REPLIES 7

       if(value == 1 || value== 2 || value == -5){

Please confirm how these values are getting calculated what is 1 2 & -5 from where you are getting this

Hi Aravind,

 

1, 2, & -5 refers to the backend value of the state choices. You can find the values under configure dictionary or show choice list by right clicking on the field label.

 

If you find my answer useful, please mark my  answer Helpful !! 

Thank you.

var item = new GlideRecord('sc_req_item');
item.addActiveQuery();
item.query();
while(item.next()){
       var label = item.getDisplayValue('stage');
       if(label == 'Completed'){
       var value = item.getValue('state');
       if(value == 1 || value== 2 || value == -5){
       item.setValue('state',3);
       gs.print(value);
       item.update();
}
}
}

 

Can you help with this with encoded query instead of calling in while loop