REMINDER
Before function call ... Execute custom javascript code
-
is it possible to halt the execution of the cloud backend? For example, when a user presses the cancel button in an alert box which is invoked by pressing a button that will then trigger a cloud backend ...
-
Great question @Dick-Honing!
-
No you can't, and we are not able to do it.
In micro-service architecture you're not supposed to cancel the execution of it.
It has a timeout and you can still code inside some conditions that would stop a long loop, but you can't stop it from outside. -
in the meantime, I found a work-around. I've created a second 'Delete' button to which I attached a function that asks the user if it's OK or to cancel. If OK, I then call the (hidden) button to which the cloud backend action is linked, i.e. document.getElementById("delete").click();
The downside is this approach, is that you've got to manually ad a id="delete" to the input field. If you ad an identification via PageBuilder, the id get's added to the surrounding element and then it doen not work.
@Wassim long story short; is this a proper approach or it there a better/easier way?
-
Hey @Dick-Honing I'm sorry but I don't get the whole situation to understand what you're trying to achieve.
Can you send screenshots and give some more details? -
@Wassim the sitiuation is actually quite simple; I’ve got a button that is going to delete a record and before I wat to ask the user if he/she is sure about this. If OK delete or else cancel ...
-
Hey Dick,
when you configure your cloud backend action, check the checkbox "Execute custom javascript code"
Then click on Edit code:
There you can test if a condition is valid or not and return false to cancel the cloudbackend action before it starts!
If the condition is valid you can return true to continue the execution -
Oh ok I see! Yes, Joseph's solution is exactly what you need!
-
@Joseph-Benguira That's it Thanks!