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

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.

Community Alums
Not applicable

Fix script ?

 

@dhanrajb

Yes, Ofcourse you can do this in fix script

 

Regards,

Dhanraj

Community Alums
Not applicable

I have run the fix script,it is working for most of the records but for a few records it is not working.

I have checked BR but still did not find any developments for these records.