Backendless DB object change

Hello community.
There is next task: I have a codeless method that, if specified conditon is fulfilled, should change cim_id parameter of specified record in table HP_list (see where_clause input of Load Table objects block). But instead of that, it creates new record. Image of part of that method is below:

HP_list table (part):

image

HP_list table after method executing :

image

As we can see, new record to the table has been added isntead of changing of current (in this case parameter hp_sn=‘12345678’, so, accroding to logic, parameter cim_id of the row when serial=‘12345678’ should be changed instead of creating new record)

I created above mentioned method according to video instruction:

Probably there is something I did incorrectly. Any ideas how to solve above mentioned task?

Hi, @Oles_Lototsiy

You need to make sure that the CurrentHP variable contains the objectId of the object to be updated. If the objectId value is not passed, a new object will be created instead of updating.

Regards,
Marina

ObjectID is not passed - I checked it. It seems to me the reason of that issue is using of create list with method. I removed it and now method works correctly (at least it seems to me). Updated method looks like:

Hi Oles.

The “Load Table objects” always returns a list, even if you specify page size of 1. Your change was correct because previously you were wrapping the list returned by “Load Table objects” (which is a list) into another list.

Additionally, I recommend using the “Update object” block instead of “Save Object in Backendless”.

Regards,
Mark

Where “Update object” block is located? I saw Bulk Update block only.

Hi Oles,

I apologize if I confused you with my response. The “Save Object in Backendless” block uses the “upsert” operation to create and update new objects. The operation depends on the presence of objectId in the object. If the objectId is present, the object will be updated, otherwise, it will be created.

Regards,
Mark