Set Value of a choice as a reference field.

Pratiksha Lang1
Kilo Sage

Set Value of a choice as a reference field. There is this field role which is choice as a reference and it's having values table records as DE and I want to replace that DE with Duty Engineer. I want to do this more than 1000 records.

 

Note now DE choice is removed from the reference table and Duty Engineer is present in choices.

 

I have written the code but it doesn't work on the background or fix script

 

var getInput = new GlideRecord('x_amspi_smdrs_app_input_ola');
getInput.addEncodedQuery('roleLIKEDE');
getInput.query();
getInput.setLimit(10);
while(getInput.next());
{
getInput.setValue('role', 'Duty Engineer');
getInput.update();
}
5 REPLIES 5

Aniket Chavan
Tera Sage
Tera Sage

Hello @Pratiksha Lang1 ,

Please give a try to the code below and see how it works for you.

 

// Update 'role' field in x_amspi_smdrs_app_input_ola table from 'DE' to 'Duty Engineer'

var getInput = new GlideRecord('x_amspi_smdrs_app_input_ola');
getInput.addEncodedQuery('role=DE');
getInput.query();

while (getInput.next()) {
    getInput.setValue('role', 'Duty Engineer');
    getInput.update();
}

 

Let me know your views on this and Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks,

Aniket

Hi @Aniket Chavan  I already tried this but this doesn’t work

Hello @Pratiksha Lang1 ,

 

I want to confirm my understanding of your requirement. If I'm not mistaken, you have a reference type field named "role," and there's a corresponding table containing records for different roles. In this table, one of the choices has been updated from "DE" to "Duty Engineer." Now, you are looking to apply the same change to the existing records in the "x_amspi_smdrs_app_input_ola" table, ensuring that they reflect the updated name "Duty Engineer" instead of "DE." Have I accurately captured the essence of your request? Please correct me if I've misunderstood any details.

Hi @Aniket Chavan  it is working now with updateMultiple