populate exiting data in other field and keep caste field as others

Community Alums
Not applicable

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.

 

Thank you

1 ACCEPTED SOLUTION

dhanrajb
Tera Guru

Hi @Community Alums ,

 

Does the 'Caste Field' still holds the string value even after changing the field type. You can write a BG script to populate the values.

 

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

 

Regards,

Dhanraj.

View solution in original post

7 REPLIES 7

Ahh!! Are those records have "caste_field" not empty? Because we have condition, which will restrict the "caste_field" empty records from updating.

 

Did you give the correct filter? Not sure what is missing. Did you see anything different for those records?

1_DipikaD
Kilo Sage

I run this script using setWorflow(false),it was working fine . But i don't know why i am getting unexpected result on those updated records since a few days .  Is it possible to get previous record as it was before ?

 

image.png

 

@dhanrajb , @Dr Atul G- LNG ,@Sandeep Rajput ,@Ravi Gaurav

Hi @1_DipikaD ,

 

Can you please elaborate what is the exact issue you are facing? and I believe reverting back all those records will be a complex logic to perform.

 

Regards,

Dhanraj.