I’m trying to set up an event handler and have read through the documentation and support forum topics, but I have not been able to find how to make it work.
I have an action in my front end app that changes a boolean field in a database table from false to true. When that happens, I would like to use an event handler to send an event to mixpanel.
This is the codeless logic I have used, what am I doing wrong?
What I am trying to achieve is to trigger an action when the wizardComplete changes from false to true. So in the request (before change) it is false, and response (after change) it is true.
I don’t know how to test this in Backendless, but have tested by checking the Mixpanel environment and the event is not being sent when the wizardComplete field is changed.
Is there any documentation that helps explain this in more detail for non coders? Or somewhere that I can see the body of the objects and other data from the event listener?
I’m sorry but I don’t understand from your response how to fix this using the codeless logic blocks
I’ve read all of that documentation, but I can’t see anything there to explain how to use the codeless blocks to access data from the request and response bodies
The documentation says to use the get property of object blocks for the user example:
As you can see, the Response object contains the error = null and result = Person object fields. According to the Response structure, the Person’s name can be retrieved this way:
Thank you, the real time logging is what I needed to troubleshoot and understand more about the objects.
I have two more questions:
The change to the field in the database is triggered by a webhook back from an external API service, which has been coded in JS. This isn’t triggering the event handler even though the database is updating. I have tested with a button in UI Builder that updates the same field in the database and this does trigger the event handler. Is there something I can do to make sure the event handler triggers from the external webhook?
Both the request and response property show the field to have been true
I’ve watched some more videos, re-read the documentation and tried a few tests but still can’t work out if the two problems above are expected behaviour (and I need to do something different) or should not be happening.
From what I understand: there is an external call into your JS API service in Backendless. Your API service updates an object in the database. When this happens, a real-time listener for the table where you updated an object is not triggered. Is that correct?
Would it help if you could see this using the app? I have created a test account and can set it ready for you to take the action that changes the database field and does not invoke the event listener.
Our support policy is that we do not debug customer apps. If there is any extraneous logic, it will be required to understand it when we look for the problem. As a result, we ask for a minimum reproducible example. It can be as trivial as what I have put together for you.
Ok I understand that, I’ll try to find a way to reproduce the issue and keep working on testing problems as well.
The other issue I have is that when the event handler is triggered, the request and response both come back with the changed value for the database field.
From what I understand in the documentation, the request block should give the value before the object is updated, and the response block should give the value after it is updated:
It isn’t clear to me how to get the value from the database field before the change and the value after the change and be able to use both to trigger logic.
Could you please describe the entire flow one more time? I thought I understood it and you confirmed, however, now I see you’re using an event handler (After Update) and that actually changes a few things. If you could put together a diagram of the information flow, it would help me understand the scenario better.
Sorry yes my fault, it’s an event handler not a listener.
Step 1 - The user is redirected to DocuSign to sign a document, this is presented in the app but they are sent to DocuSign to complete this process.
Step 2 - When the document is signed, the following JS code saves the document in the files section in a new folder for that user based on their objectId, and updates 2x fields in the SignUp database table (step7Complete & wizardComplete)
NB - I think this is the problem with the event handler not being invoked, and I am working to change this code to an API call to see if that fixes this issue
Step 3 - The user is redirected to the same page that they left from, but because the database fields have been updated, they see a different section through onBeforeMount logic
Step 4- At this point, I had hoped that my event handler would record that a change had been made to the database and would perform a number of actions.
Step 5 - Because the above flow does not invoke the event handler, I have created a button that will invoke the handler. This works and prints to real time logging.
But something is wrong with the logic on the afterEvent handler because the request and response item both show the field in the database to be true - but before the change it was false. This means I can’t use the if/then logic above to trigger my actions.
From reading the documentation, I thought the request section would show the state of the database field before the change.
In Step 2, where does the code run? Is it in an API service that is called by DocuSign? Is it on the DocuSign side?
In Step 4, is the event handler “After Update” you showed earlier? If so, where is the actual Update API called from? I didn’t see anything in the previous steps that anything would be updated - the code you showed is for bulkUpdate which doesn’t trigger the After Update handler.