Troubleshoot Fix script issue in QA and UAT

1_DipikaD
Kilo Sage

Hi All,

Actually before caste field was string and recently i made this a choice field so the value entered before is not present in my choices now. So I want those values should be populated in other caste field and caste field should become others which is present in my choices.

I have a choice field for caste and it has already contained some existing records . Also I have string field named "other caste" to enter data manually when user selects others in caste field. Now I want to populate the existing records which contains data out of the options in choice field i.e. on caste field, to be populated in the string field named 'other caste' and make choice field (caste field) as others.

 

*To achieve this I wrote a back ground script:-

 

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();
}
}

After running the Fix script I noticed it is not updating a few records and I used setWorkflow(false); to fix this and it worked fine in DEV  but when I moved the development to QA and UAT still I am experiencing most of the records got updated but still a number of records are not getting updated . I want to know how to fix this issue ?

1 REPLY 1

Richard Hine
Tera Guru
Tera Guru

I think I would definitely have if(!gs.nil(grTable.caste_field)){}

 

I think I would also do grTable.other_caste = grTable.caste_field.value;

 

In essence I would debug this by adding an additional criteria restricting the query to a record I know should be updated and outputting the value of other_caste and caste_field.

 

My personal preference would be to put this in a fix script, encapsulate the logic in a function containing a try-catch block with appropriate error handling and logging, will probably save you some time in the long run.

 

Hope this helps!

 

Rich