Adding an additional database entity attribute to an existing localstorage entity
Question
Application Type
Mobile
Service Studio Version
11.10.16 (Build 40208)
Platform Version
11.11.2 (Build 29094)

Hello. 

I have created several localstorage entities from core database entities.  

In one case I need to add an additional database entity attribute to an existing localstorage entity.   There does not seem be an easy way to accomplish this task, other than deleting the whole localstorage entity and then recreating it again from the database entity to include the extra attribute.  

Doing this approach makes me nervous since I am using sync on the localstorage entities.  

Q1:  Is there a better way to add a an existing database entity attribute to an existing local storage entity? And,

Q2:  How is the data sync impacted if you have to delete a local storage entity and then recreate it?

Thanks in advance for you input.

mvp_badge
MVP

Hi David,


You can add the extra attribute and use it as all the others, without having to recreate the table. You will have to adjust your sync to populate it just like every other field.

The thing to be careful is the default value of that entity. For instance, if it is a boolean, all records will have the value False, or if they are numbers they will have 0 and so on.

You will probably would need to make sure that these extra attribute starts populated with a value different than the default one. If it's a server side entity, a good approach is to have a timer, running on publish, which updates the extra attribute not yet updated to the right value. For the local storage, an approach I use for these scenarios is creating a handler for when the app is updated (when the user opens the app with the new version, an update will take place - by default there's a feedback message saying to the user the app was updated - and the handler will be triggered). Something like this javascript code on the OnReady of the Layout:

This will trigger the client action in the Layout called Handler_OnAppUpdated, which is where I would place the logic to update the extra attribute in the local storage so the user can have that field filled correctly when starting to use the app under the new code version.


Hope it helps.


Kind Regards,
João

Thanks Joao for responding!  

Hopefully there will be few if any additional requirements for the local entities...the process is heavy.


Best Regards,


Dave

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.