How to restore values of a deleted field?
Hi,
Lets say I'm editing the development environment of an app. The app has a form, I deleted a field named "field1". But in the production environment, there are several records of the form that contains values in the same field. Now in the dev environment, if I add another field with the same display name, same link name and same type as the previously deleted field, and once I publish the app to production, will the values from the deleted field be automatically transfered to the newly added identical field? If no, is there an easy way to do the transfer manually?
One way I can think of is running a custom function that does the transfer.
Here's how to do it:
- Before publishing to the prod environment, export the records as a csv.
- Open the exported csv file, convert the two columns "ID" and "field1" to key-value pairs with the key being the record ID and values being the field values.
- Publish the app to prod environment.
- Once published, run a custom function that would take the key-value pairs as input and add the value to the new field against the record ID in the key.
The function would look something like this:
- void transferValues(Map pairs)
- {
- for each pair in pairs
- {
- rec1 = Add_Form1[ID = pair.key];
- rec1.field1 = pair.value;
- }
- }
If you have done something like this before, please let me know if it works.