Fix script giving an unexpected result

1_DipikaD
Kilo Sage

Hi All,

Before I had run the following script on alphabet field where the requirement was when I select others in alphabet field the existing value should populate on other alphabet field.

 

var grTable = new GlideRecord('table_name');
grTable.addEncodedQuery('filter');//use the filter in list view and copy the query.
grTable.query();
while (grTable.next()) {
    if (grTable.caste_field) {
        grTable.other_caste = grTable.caste_field;
        grTable.update();
    }
}

1_DipikaD_0-1728886616001.png

 

 

It was working fine but few days back I notice  the mentioned fields are full of with value as others instead of the existing value. Till now I am not able to find out how it is happened .

 

Is it possible to get previous record as it was before or any other solution to get the expected result ?

 

For more info also refer to  :-  Solved: populate exiting data in other field and keep cast... - ServiceNow Community

 

Thank YOU

 

 

5 REPLIES 5

HrishabhKumar
Kilo Sage

Hi @1_DipikaD , previous replies form @Harsh_Deep and @Eshwar Reddy  should work as well. just to add you might wanna check the the type of both field they should be same, if not then try stringifying the data using .toString() as suggested by @Eshwar Reddy .

 

Thanks,

let me now if any of the solution worked.