beforeUpdate not called

I have created an API service that searches for a game object in a table and updates some of its values.
I then call the save function ‘Backendless.Data.of(Games).save(game)’ and return the promise.
I know the game object gets updated but my beforeUpdate Handler is never called. Can someone please explain why this is happening. Here is my Code for the handler:
Backendless.ServerCode.Persistence.beforeCreate(‘Games’, function(req) {
//add your code here
console.log(“got here”)
return req
});

Hi Asher,

is the handler deployed? Does it show up with the green label in console?

Regards,
Mark

Yes it appears to be deployed and enabled.

Does your app create a new game or updates an existing one?

It creates a new one each time the service is called.

How did you verify that it was not invoked?

i called console.log("…") with a message but nothing was logged. But I do see the new object in the Game Table each time.

What’s your app id?

8539B156-D381-D5D5-FF15-D8345E7C6C00

The event handler you have deployed is codeless and it does not produce any logging output.

just to clarify, are you saying it is unable to log output?

When I download my production service event handlers I see the functions making the call to console.log.

Of course it is able to log output, it is just you didn’t put any logic in there to do it.

I apologize for the confusion but on my end it says I do have logic there calling the console.log function.

When I navigate to my handlers in servercode under production I see two handlers that call log.

That explains it… When you invoke an API from business logic (such as API service), other business logic scripts (such as event handlers) are not triggered. It is a limitation now, it was done to avoid recursion in business logic.

Regards,
Mark

At the time when you shared your app id, the only event handler which was deployed (green label) was the one in Codeless. The implementation of that event handler did not have any console.log logic. Does it make sense?

Now, have you made any changes there? Perhaps deployed your JS handler?

Yes I redeployed and now have two event handlers in production (with the green label) that should be calling console.log however I am not seeing any statements in the log file.

Please create a user account for me to test with (since only authenticated users can create games). I would need an email and password.

Thanks!

‘test@test.com’ + ‘tester’

Thanks. I created an object:

http://support.backendless.com/public/attachments/996b3b3dc86bfd763f782a5b842d006c.jpg</img>

And the log output is there:
http://support.backendless.com/public/attachments/cb81fd6102482e2320afe435cc8b5e58.jpg</img>

interesting, if you directly create a game using the rest console the beforeCreate is invoked. Why is this not the case when I create an object using a custom service?