Issue with Choice values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2024 04:04 AM
Hi Team,
In incident table we have a choice field "Related to".
there is duplicate choice label as bellow:
Label | Value |
Cloud computing | Cloud |
Cloud computing | Cloud computing |
There are 50 records on each choice label.
Requirement is to change the value to Cloud for both.
After making the changes:
Label | Value |
Cloud computing | Cloud |
Cloud computing | Cloud |
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2024 04:35 AM
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)));
}
Thanks
dgarad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2024 05:06 AM
I tried same code, still same output.😓
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2024 05:40 AM
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.
Thanks
dgarad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2024 05:52 AM
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