On-Device Storage - Create Record with Custom ID

When I use create record flow function for local storage, I don’t see “id” field to update.

Do you mean the ‘set item to storage’ flow function?
It has an input field for ‘item key’ which identifies whatever is stored in that moment.

I’m having the same problem Atakan. It seems the Create Record flow function has changed compared to the client-side storage tutorial by @Mevi. In the tutorial screenshot, you can see that the Create Record custom object binding page makes the ID field available. Now it does not.

I’ve seen a few suggestions about using a loop with Update Record, but I couldn’t re-create the solution.

@stayfoolish Is the ‘set item to storage’ flow function the better way to access client side storage?

Perhaps I’m missing the obvious, but I can’t store anything on the device at the moment.

Thanks,
Bryan

Actually, the Set Item to Storage, and Get Item from Storage is working for me now. Maybe the Create Record function just won’t work with a custom ID anymore (since a recent update I assume). In my case it kept getting overridden at run time with a proper UIID, not the one I was trying to provide.

On-device storage has some differences to client-side storage – we will update the docs! On-device storage automatically generates the ID, so it can not be customized. But you can always use set/get item to/from storage instead.

Can you explain it in a little details @Mevi. I am having some problem while creating new record. actually I am firebase to store my database but I also include a download option for user to download it to his device by using on-device storage. But what I really want is to check whether it is a duplicate entry or not while creating new record… I couldn’t understand how to check for duplicate entry…
the flow is simple create new record If the article_id is not present in local database…

Thanks Mevi! I was able to use the Set/Get Item to replicate what you show in the Tutorial. When you say On-device storage has differences than client-side, do you mean the changes in the Data Resource setup (meaning AppGyver changes from older version to current version)? I guess I’m asking what we should consider before choosing one approach over another?

Well, this is bad news for my offline storage… Is there a way (flow, formula, etc.) to make my data resources offline?

In the description, it says “till the app restarts” but I need it to store the data locally. Would it work?

1 Like

The Set Item to Storage does persist across app restarts. That is how I’m using it now. Also from the Set Item reference: “Storage is persisted across app restarts.” Set item to storage - AppGyver

Then when I get the item, I use Merge function to save it to AppVar. There may be an easier way to do that, but it’s working in my case.

Good luck!

2 Likes

@Mithun_Dey Hmm I would check for duplicate entry by getting all records (list records) and then searching for the relevant identifying field, and creating a new entry if nothing is found.

@BryanB On-device will support some upcoming features such as pagination etc. On-device will replace client-side storage – set/get item from storage can be used in the future too, but new client-side resources can’t be created, only on-device storage resources.

@Atakan_Tokgoz like @BryanB said, sounds like the set item to storage flow will work the best in your case :slight_smile:

Thanks for the reply Mevi. Helpful as always!

1 Like

@Mevi Thanks for reply… I am doing exactly that… But can you teel me about that searching part… What should I do to search the same field with id… as offline databse includes its own id which cannot be overwritten…

Thanks @Mevi… It’s solved… :heart_eyes:

1 Like

Hi @Mevi

I am using client side storage a lot and have been using create record, update record and delete record by using the same id, that I set.
If the new On-device storage is setting its own id, I am not sure how I can make sure the right record is updated when i can’t set the id.

Dan

I’m sorry I’m not sure if I understand you correctly – why would you not be able to update a record if you haven’t chosen its id? If you have the record in a variable (gotten from e.g. get record or list records) you can just… refer to that id when calling update/delete record? If that’s not the case please show some screenshots or something that provide more information on how you’re doing this :sweat_smile:

Hi @Mevi

I have, let say, 4 record saved in client-side with id a, b, c, & d. Now I want to update record b, on clien-side using update record I could set the id, of the record I wanted to update.
With on-device, I don’t have that option of selection what id I need to update, or at least I cant find it.

Not sure if this makes more sense :grimacing:

Ok, well, it does sound like you want to have a static id used in the UI, when you could instead use a dynamic id :sweat_smile: If you insist going the static way, use the get/set from storage flows. If you’re willing to learn the way to do it in the dynamic way, I suggest looking through the lessons here, and there are further lessons on how to use data available as well. These concepts are not specific to rest api or any other specific data resource type :slight_smile:

Hi @Mevi

Not sure I follow you. I have used client-side storage for over a year now, very simple and no issues. Its now been changed to On-devide storage and, what was once very simple and logic to set up, now seems difficult or impossible. :man_shrugging:

I have attached pictures to show what I used to do

Yes, it’s impossible to use static ids with client-side storage now. If you need a field you can set statically, you can make another field in addition to id and use that. Then you can find the correct item and its id with formulas, something like LOOKUP(FIND(dataVars.allMessages, item.my_own_id_field=="A")).

1 Like

Thanks Mevi, yes you are right, not so simple anymore :pensive:

If I was to go with your first idea, and use the dynamic id, using what I have done before, how would I make sure the right record is updated now the id is dynamic?