Issue with Choice values

sainath3
Mega Guru

Hi Team,

 

In incident table we have a choice field "Related to".

there is duplicate choice label as bellow:

 

LabelValue
Cloud computingCloud
Cloud computingCloud computing

 

There are 50 records on each choice label.

Requirement is to change the value to Cloud for both.

After making the changes:

LabelValue
Cloud computingCloud
Cloud computingCloud

 

After making the change, in list view field value is showing in blue color.

After running below script we are getting : Cloud computing instead of Cloud.

 

var gr=new GlideRecord('incident');
gr.addEncodedQuery('numberSTARTSWITHINC97384');
gr.query();
if(gr.next()){
    gs.info(gr.u_related_to);
}
Output: Cloud computing
 
Can anyone help me here
5 REPLIES 5

dgarad
Giga Sage

Hi @sainath3 

please try the below code.

var gr=new GlideRecord('incident');
gr.addEncodedQuery('numberSTARTSWITHINC97384');
gr.query();
if(gr.next()){
    gs.info(gr.getValue(u_related_to)));
}

 

If my answer finds you well, helpful, and related to the question asked. Please mark it as correct and helpful.

Thanks
dgarad

I tried same code, still same output.😓

 

var gr=new GlideRecord('incident');
gr.addEncodedQuery('numberSTARTSWITHINC97384');
gr.query();
if(gr.next()){
    gs.info(gr.getValue('u_related_to'));
}

  I have tried PDI it working.

dgarad_0-1716468020382.png

 

If my answer finds you well, helpful, and related to the question asked. Please mark it as correct and helpful.

Thanks
dgarad

amaradiswamy
Kilo Sage

Hi @sainath3 ,

 

This is expected behavior, because system stores only choice value as the field value. Since you have changed the choice value after the records already created that's why the record still holds the value of choice when it was updated.

 

You can try below

 

var gr=new GlideRecord('incident');
gr.addEncodedQuery('u_related_to=Cloud computing');
gr.query();
while(gr.next()){
   gr.u_related_to = 'Cloud';
   gr.setWorkflow(false); // This is to not to send any notifications & business rules as you are just correcting the data
   gr.autoSysFields(false);// This is to not to update updated by & Updated
    gr.update();
}

 

and run your script again