Forum Academy Marketplace Showcase Pricing Features

Data in Custom State of Reuseable Element not being Saved in Database

I have an app where the user signs up after going through some steps, filling some forms, selecting some choices, etc, and I do not want to store the forms’ data in the database unless the user gets to the sign up page and actually signs up. I thought the best approach will be to save the data in the Reuseable Element Custom State and then call it up later from that Custom State after the user signs up and then save the data with the sign up data in the database.

I tried it and it didnt work. i.e. the data from Custom State didn’t save in my database, but the sign up info did save in my database. Wonder what went wrong? Note the data I stored in the Custom State is for a different Data Type than the User Type.

Can you explain the process you’ve used here (i.e. what your workflow looks like)?..

Hi Adam, thank you for responding…


This is screenshot I used for saving in Header Custom State.

Workflow for one of the fileds - Campaign Message Custom

Workflow for saving Custom State to Database

It looks like you’re navigating between pages here…

Custom states only exist on the page and will be cleared anytime the page reloads, so if you’re using a ‘go to another page’ action the the header custom state values will be cleared when your user goes to the new page.

Which explains why nothing is saving (i.e. the header custom state values will be empty).

There are a few different ways to do what you’re trying to do…

The simplest way (in my opinion), and also probably the best UX, is not to use multiple pages for this at all (unless you have a specific need to). Rather just keep the user on the same page, and use separate groups for each step in the process, showing and hiding the relevant groups as your user moves through the sign up process.

Not only will that be much faster than navigating to a new page and waiting for it to load, but there will be no need to use any custom states at all, as you can simply refer to the relevant input values at the final stage.

If there’s a particular reason you want/need to use multiple pages here, then you’ll need a way for each subsequent page to access the data from the previous page (as I said above, you can’t use custom states for that).

There are basically 3 ways to do that:

  1. Through the database
  2. Through URL parameters
  3. Using cookies

To be honest, the simplest method would just be to create the object in the database, and modify it as the user goes through each stage, although you specifically said you don’t want to do that.

In which case the best option will be to send the data through key/value pairs as URL parameters, then read the data from the URL parameters in the subsequent page using ‘Get Data From URL’.

Alternatively you could store the data in some session cookies on the user’s browser and read the cookies on the subsequent pages. That would require either a plugin, or some Javascript.

So there a several options for this, but custom states aren’t one of them unless you opt to keep everything on a single page (in which case you won’t actually need any custom states at all).

If it was me, I’d use a single page, as it keeps things simpler, and faster - but if you want to navigate through multiple pages, without saving anything in the database, then using URL parameters is your best option.

Thank you so much Adam for the explanation.
I trule appreciate it!
I will try to put in one page, will let you know how it went.
Thanks a lot!

Hi Adam, I put them in one page, the index page and it worked.
Thanks a lot!!!

1 Like