Business logic: beforeFind, afterFind not called

hi there,
I’ve been using business logic to add certain functionalities to our application. I can use beforeCreate and afterCreate without any issues, everything gets called, even when using third party libraries (for example I’ve integrated Stripe payments).
Now I tried to do a similar thing using find, however it never gets called (I’ve been in debug mode only, but everything else works well in both debug and production).
My code is really straightforward as I am not adding any logic yet (I changed only the actual table name, see below).
I’m on v3, anything else I should be doing differently? Thank you for your help, I’ve found the documentation and support here to be really excellent.

/* global Backendless *//**
* @param {Object} req The request object contains information about the request
* @param {Object} req.context The execution context contains an information about application, current user and event
* @param {Person} req.item An item with changes
** @returns {Person|Promise.<Person>|void} By returning a value you can stop further event propagation and return* a specific result to the caller*/


Backendless.ServerCode.Persistence.beforeFind(*table name*, function(req) { //add your code here console.log( "beforeFind" ); 
});

Hi Marco

Could you please provide your APP_ID please?
And I guess table name it’s just a typo, you have a right table name there without stars, right? =)

Thank you for the quick reply, and yes I have the correct name in there :slight_smile:

App ID: 9088AF67-1648-1726-FF09-A51862BF1A00

looks like the issue with Roles Permissions for that table, did you try to find objects as AuthenticatedUser or not?

I just tried to download your BL and run it in Debug, afterFind handler works

yes, authenticated and with all the rights for the table I was trying. I do get the find to work (so I get the entries I am searching via JS APIs on the web fronted I am developing), but I don’t get the afterfind triggered in debug mode for some reason.

could you please provide steps for reproduce the problem, if you need to share a some secret data you can do that via sending to support@backendless.com

What I did:

  1. download you BL from Console
  2. add “console.log(‘after find’)” to afterFind handler
  3. run it in Debug
  4. invoke a simple cURL with JS API Key
    and I can see that handler works

http://support.backendless.com/public/attachments/28353daa2f1f76ae6fc014c67a5a88f8.png</img>

thanks Vladimir. In case this helps: I was now doing other operations and I saw the after find output coming out, so I did some additional testing, and basically I get the after find called when I create an object (same as the after create) instead of when I search for an object (using find). Not sure why this would be the case, I will email with more details, thanks.