Need to update new field values with values from the old fields?

Kiran_25
Tera Expert

Hi I have added new fields to a form to replace some old fields. I need to make sure that I dont lose any historical data and would like to map the data from old fields into the new ones. 
I have already removed the old fields from the form however and added the new ones in.

1 REPLY 1

yashkamde
Mega Sage

Hello @Kiran_25 ,

 

Use a Fix Script OR  Background Script to copy data from the old fields to the new fields.

Example:

var gr = new GlideRecord('table_name');
gr.addNotNullQuery('u_old_field1'); //same if multiple fields
gr.query();

while (gr.next()) {
    gr.u_new_field1 = gr.u_old_field1;
    gr.u_new_field2 = gr.u_old_field2;
    gr.u_new_field3 = gr.u_old_field3;
    gr.update();
}

 

And If the data is still being update then consider adding a temporary Business Rule to keep the fields synchronized !

current.u_new_field = current.u_old_field;

 

If my response helped mark as helpful and accept the solution.