Help with a codeless event handler

Hi Mark,

Step 2 is called in Backendless:

After doing some more testing this morning, I suspected that bulkUpdate is the problem for why the event handler isn’t invoked and am working to fix this by changing the code to have an API call instead.

However I have also created a button to invoke the eventHandler with this logic:

image

This does invoke the handler

image

But both the request and response are showing as true.

When you make an API call from Cloud Code (i.e. API Service in your case), event handlers are not invoked. This is done to prevent circular invocations.

As for the value of the property, could you try disabling the following blocks and see what the logging shows:
Codeless - Backendless Support 2022-03-18 10-29-29

Ah ok, thank you Mark. We will have to find another solution, maybe a webhook to trigger the actions needed.

The problem is the same with the response and request items, are they meant to be different?

Hello @Luc_Zentar

Do you mean the same data in Request Item and Response?
It is a normal practice to add data from request to response.
In some cases, you don’t have request data but you have response. You can get info about request data from response

Regards,
Viktor

Hi Luc,

Here’s a test I did:

My logic in the page to save an object:
UI Builder - ConsoleDemo - Backendless - Google Chrome 2022-03-21 19.17.47

My logic in event handler to display request and response:
Codeless - BL - ConsoleDemo - Backendless - Google Chrome 2022-03-21 19.17.27

And the log output I get is this:

As you can see, both request and response show the same value I am passing from the client side. The system is working as expected.

If you believe there is a problem, please create a small reproducible example that recreates the problem you’re experiencing.

Regards,
Mark

Thank you, I was trying to use the handler to trigger logic when a field in the database changed from false to true.

I thought that the request item would return the field’s state before the change ‘false’ and the response item would return the field’s state after the change ‘true’.

Now I know this is not the expected behaviour, is there a way for me to achieve this with something else?

Hi @Luc_Zentar ,

You can use beforeUpdate event handler instead. This event handler receives changed record as an argument. So you will be able to retrieve from the database existing object, make your check and make API service call if it is required.

Regards, Andriy