Codeless help required

Hello,

We are in the final stages of launching our app and we have decided to move some of the code server side utilizing Codeless. We have hit a small speed bump and request some assistance if possible.

We have 2 data Tables Venues and Tickets there is a one to many relation between Venues and tickets.

In the Tickets data table we have a “status” column and what we are trying to accomplish is when the “status” column is updated to 4 to create a new object in History data Table and delete the object from Tickets data table. The new created object must include the ownerId and the venues.objectId from the previously set relation.

Everything works as expected however we can seem to get the object id from the relationship the realtime logger keeps logging undefined.

i have attached a screen shot of our codeless block.

in the dataBrowser we have autoload relation on. and on the create object block for the venues property we have tried both response item and the request item to no avail.

and this stage we are certain that the relation is not being loaded when the codeless block is being run.

we have also attempted to use Screen Shot 2020-09-06 at 12.29.49 PM however the “venu” property is not being shown.

Any ideas how to retrieve the parent object id from the relation?

thank you

Hello @Omar_Darwish

Please provide your AppID

Regards, Vlad

Sorry Vlad,

App ID: 2E6E6142-3600-6FA9-FF2E-462B0F504F00

Thank you

Hi @Omar_Darwish,

The “venu” property is a relation, this is the reason it doesn’t show up in the drop-down. The relations are not processed in the object update API request, therefore that information will not be available.

Regards,
Mark

Hey Mark,

Thank you for the response, we kinda figured that part out but is there a way to retrieve objectId for the related object via codless?

Yes. you’d need to make an API request to retrieve the related objects from the database. Each object will have its objectId.

It just trying to wrap my head around this, the request item should have the objectId for the related object accessible because this is an event handler after update.

Otherwise which api call should we use to load the related object?

When you send an object to Backendless to update it in the database, any related objects in it will be stripped away.

Dear Mark,

Thank you for the info, We really have been trying to get the relation to load however we are wits end here. We are not looking for someone to do the code for us however any guidance on which api call to make would be really appreciated

If the request item has objectId for the related object, then you should be able to retrieve the related object using that objectId.

Perhaps if we step back and you provide a very detailed description of what data you load from the server, what data you send to the server and what changes you need to implement, it will be very helpful.

Sure thing Mark,

So we have 2 tables Tickets and Venues…each Ticket has a relation to a Venue. The Tickets has a column called status, what we are trying to accomplish is have a codeless event handler afterUpdate if status = 4 to create a data object in a Table called History which has a column that should be the objectId of the related Venue.

We don’t want the history to be related to any table hence we just want to retrieve the related venue’s objectId.

hope this clarifies a bit.

Hi, @Omar_Darwish

Looks like you’re trying to get requestItem['venu.objectId']. Using nested string path isn’t supported here. Try to use another GetProperty block instead.

Regards, Igor

Dear Igor,

I am we can only find one get property block in the codless object list. and as i mentioned earlier we have tried accessing the venu property of the request item and the response item to no avail. There must be away to retrieve the related object as the reference in the data browser is alive and well :laughing:

after some digging we have realized that the updated method dose not load the related object.
is there a way to load the relations of the request item and storing them as a variable then accessing the related object objectId from the stored variable?

i hope you can lead us into the right direction.

Hi Omar,

The aglorithm in your event handler should be like this:

  1. Retrieve related Venue for your Ticket.
  2. From the retrieved Venue get its objectId
  3. Save an object in the History table

If we are on the same page at this point, please let me know which of the steps above you need help with?

Regards,
Mark

Hey Mark,

The saving part is working flawlessly, it’s just we are unable to retrieve the related venue.

This is how you can get objectId of the related venue:

Thank you Mark.

Your a true hero.

Best Regards,
Omar