Hi all, I have a custom field in a bundle that I w...
# general
s
Hi all, I have a custom field in a bundle that I want to change from type Freeform Text to Integer without loss of data for my customers. I am not sure the best way to go about this. If I were to simply change the field type, all data in that field would be erased and that would be chaos for the bundle customers. Is there a way I can utilize a bundle installation script to run the next time a user updates this bundle that would copy the data, change the field type, and repopulate the data perhaps? I've never written/used an installation script before. Wondering if anyone has gone through something similar, there must be a way to do this without complete loss of data. (the values in this field ARE integers, theyre just stored as freeform text currently)
k
create a saved search for this field, download it, reset the field, upload data into the new field
s
Can this be done in an installation script so that it occurs on all customer instances upon updating the bundle?
k
have no idea, I am on functional side
s
no problem, still thank you for the insight into being able to do this with a saved search potentially 🙂 if anyone else knows how i could do this for customer instances on update, pls lmk
👍🏻 1
p
I haven't done this before, so just spitballing an idea. I believe there is a beforeUpdate and an afterUpdate function in the bundle initialization script. In the beforeUpdate, you could run a search for all records with that field populated that would return the record type, id, and field data. Create a file from the results and save it to the document library. Include a Map/Reduce script, that gets installed by the bundle update, that pulls the file created in the beforeUpdate function. Have it go through each result, load the record, update the field with the data populated before the update, and save the record. In the afterUpdate function of the script, trigger the Map/Reduce script.