Upload client side list to api

I have made a client storage list.

When an item is tapped it adds it to the first list. and the list continues populating. Once done the total list needs to be uploaded to an API by clicking on the submit button.

The problem is I don’t find a loop that I can use to upload each item to the API.

I can replace all but that defeats the purpose because if I do a new list It won’t add the new list of items to the old list.

Is there a way to do an incremental update of a list of items?

Hi Ashley,

The database just stores your data, so it cannot for example evaluate what items are already in the list. This is why incremental changes and other data manipulation have to be made on the app side.

I would make the current list from the API available in a data variable, and use CONCAT() to add the list of new items to the existing list when the Submit button is tapped. Then I would send the updated list to the API.

Ok, thank you . I will try this out.

The problem is what happens when the app is offline. I want the app to work online and offline.

So when it is offline I want it to be able to save the data variables to a record list and once there is internet I want the list to be uploaded.

Is this something that can be done on a per item basis?

Hi Ashley, I answered a similar question about making things available offline in this thread. In your case I would

  1. Check on app launched whether there are items in the client-side storage list
  2. If yes and the device is online, upload them and then delete the list
  3. If yes and the device is offline, do nothing and just keep adding to the list
  4. If the list is empty and the device is offline, create a new list record to store data while offline

You can also do the updating on a per item basis using WITH_ITEM to add individual items to the list.

Hi Mari,

Thank you. I only have the following problem that is preventing me from continuing. I have triple checked and the objects are identical. Please can you assist?

Hi Ashley, would you still mind posting screenshots of your data resource and client-side resource schemes so I can check them too? If they are identical this error should not pop up. :thinking:

Hi Mari,

Please see below schemas:

I need to copy the one client-side to the other client-side.

Hmm, looks fine to me – are you using Get record collection to fetch the client-side data? You should be able to get it with Get Record and the ID you have given to the client-side reserouce. With that and Create Record you should be able to bind the identical resources directly.

So basically what I want to do is add a list of objects to client side datebase:

Product 1
Product 2
Product 3
Product 4

Once this list has been completed a submit button is clicked and it needs to make a copy of this list in another client-side database which uploads the order to the API. This upload function will first check for internet access.

Once the internet access is found it needs to upload each record to the online API.

The biggest problem I have is making a replica client database from the existing single line items that have been added.

I hope this makes sense.

Thank you for your help so far @Mari

Hi! Sorry to jump in and if my answer isn’t on the mark, but sounds like you need to make yourself some looping logic to go through the list of client-side data. I would start with an if node of checking if the objectsToUpload data variable has items in it, and then create the first item in the list into the API, delete the item from objectsToUpload, and then connect that node back to checking if the objectsToUpload data variable has items in it.

Hi Mevi,

Thank you for this info.

I am busy trying what you said but I have another barrier. I am getting the following error when trying to create a record via API.

Error: TypeError: Cannot read property ‘environment’ of undefinedstatus: -1

It is the first time I have seen this.

I have attached another screen shot of the front end as well:

Yup, so it sounds like the fields you are passing to create record are not named correctly. You’re using a REST API data source, so you need to check with your backend what fields and format a POST request requires.