Questions on data update in DB

I have couple of fundamental questions on how the data setting works.

First Question:

In one of the workflows I am doing these two things.

One changes one of the fields in “Current User”
Screenshot 2020-05-24 at 7.08.29 PM

Another one changes one of the fields in a thing that I have created.
Screenshot 2020-05-24 at 7.08.14 PM

Both of these changes work fine when I see in the debugger. i.e. The values get changed in the things as shown in debugger. I have put another step after both of these to check values of both the things to see if the value has been changed.

However, both of these changes don’t get updated in the DB.

Am I doing something wrong? Do I have to do any “DB Commit” or some such thing?

Second Question:

I have a few custom states in elements which are of the data types that I have in my DB. Say, one of these is called Job.

Now I have a custom state in a page called CJob which is of Job type.

I make CJob = “Search for an item of type Job in DB with unique id”.

Now if I make changes to CJob, will it get updated into the DB? Or will it be changed in a local copy of CJob?

1º) If your query is bring the right values, do you set the fields and values that you want updated?

2º) Set state not change DB values, set state change the state of element.

I am not sure if I got your question there, but what I meant to say was that values are being set correctly into the things when I check in “Step by step” debugger.

However, same values are not reflected in DB when I go and check there.

Thanks for the answer on #2

Bumping this to see if someone would like to take a shot at it.

@mghatiya it’s not so clear right now. Best way would be to share your editor in view mode if you’re comfortable doing that

Thanks for the reply, @ambroisedlg. I have got a couple of brain waves right now. Let me try those and see if those work. If they don’t, then I’ll bug you again.

Btw, meanwhile can you suggest me if it is a known behaviour that when you pass a ‘thing’ to a Custom Event, then the changes to that thing don’t get stored in DB?

I’m note sure I get what you mean by that, can you post screenshots?

Hi Ambroise,

I am glad to share that I have managed to solve this problem. The data is getting updated in the DB. (However, there is another problem now, which I’ll talk about below)

Here are a few directions I took to debug the issue:

  • Possibly the custom event can’t change things that is passed to them, but it rather changes in their copy: This theory WAS WRONG. If you pass a thing to a custom event and it makes edits to it, they would reflect in DB.

  • Possibly the things can’t be changed when they are accessed as custom state rather than being queried from DB directly: This theory WAS WRONG too. This is the “second question” mentioned in my original post. If you have a custom state which has a type of “thing”, and then you assign a thing to it, then even if you make edits to it, they would get reflected in corresponding thing in the DB. This is good that it behaves this way.

  • Possibly a user can’t edit a thing after logging in while the thing was created when he was not logged in: This theory was very likely right. What I was trying was that user submitted an enquiry form and if he was not logged in, I was forcing them to login. After logging in, I was taking thing created before logging in (stored via cookie) and then making edits to it. But since the logged in user and non logged in user are not same, the edits even though were reflecting in debugger, they were not reflecting in DB. Now what I am doing is I am creating a new thing when user logs in, and am copying the value from non logged in enquiry to this one. It is working! Big learning!

  • Possibly “JS to Bubble” is not getting set: I am doing some javascript calculations to compute pricing, so that I can assign it to the enquiry thing. Earlier I was storing this price in the DB thing and it was not getting stored. However, the “JS to Bubble” value is not being set as I would expect it to. This is the problem I am stuck at now. I have mentioned it in this thread. If you have some insights, please do comment there.

Thanks for your time into looking into this thread. I am just sharing my learning, in case they are helpful to you or someone else in future.

Thanks,
Mukesh