How to update old records, when the field type is changed.

Ajay37
Tera Contributor

Hi,

I have a requirement to change the choice field to List field type. In this case how to update the old records, which are having choice values in that particular field.

Thanks

1 ACCEPTED SOLUTION

Anurag Tripathi
Mega Patron

Hi,

If you modify the type of the field it will delete all data from the column for all records. It might have impact on the performance also if the table is huge(data in the table)

I will suggest you make a new list column and use that going forward and remove the choice field from the form, rename it may be to ensure users don't use it in reports or something.

If you still want to update the type(not recommended) then the way to do it would be ,

  1. create a temporary field
  2. copy the data in temporary field
  3. change the type of choice field to list
  4. copy data form temporary field to list field
  5. delete temporary field.

-Anurag

-Anurag

View solution in original post

6 REPLIES 6

Anurag Tripathi
Mega Patron

Hi,

If you modify the type of the field it will delete all data from the column for all records. It might have impact on the performance also if the table is huge(data in the table)

I will suggest you make a new list column and use that going forward and remove the choice field from the form, rename it may be to ensure users don't use it in reports or something.

If you still want to update the type(not recommended) then the way to do it would be ,

  1. create a temporary field
  2. copy the data in temporary field
  3. change the type of choice field to list
  4. copy data form temporary field to list field
  5. delete temporary field.

-Anurag

-Anurag

Hi Anurag,

  1. Creating a new field will be a little problem, because there are client scripts, Ui policies written on that field. So making that existing field inactive will become a challenge. 
  2. Creating a temporary field means, which type should i need to create choice or list, and could you please provide me rough script to do this.

Thank you

 

Hi,

For 1) the scripts anyway have to be modified as currently the read and set value on a choice field, and now it will be changed to list, so the way you process these fields is different.

2) to copy the data, where is the list field pointing to now? you have to get that sys_id and then add it to the list.

Im assuming that the choice value in the field is also present on the table where the list field is referring to.

 

-Anurag

Yes Anurag, the same choice values are created in referred table.