Event handler Success or Failure trigger with java script

Is there a way in java script to trigger the Event Handler Success or Failure? It is easier sometimes to use the GUI under where the code is written to trigger events. I included a simple block of code.
However, this block of code will always be successful.
I purposely want it to trigger failure or a success.

function myError() {
let a=1;

if(a==1){
Event handlers: Success // What do I code here?
}
else{
Event handlers: Failure // What do I code here?
}
}

return myError();

Hey @clay123

I don't think this functionality is working. Instead, you can use the runScript in event handler to achieve the desired result.

3 Likes

Hey @clay123,

Not sure if this is what you're looking for, but you can use Java Script to trigger a query and define Success or Failure events directly via the code.

Here's an example I provided to another user recently:

I want to purposely make the Event handler Failure trigger. So if I set

let a=2; then the script would "Fail."

Ah okay - I see what you're trying to do, @clay123. You can deterministically trigger the Failure event handler by throwing any error from which the JS block.

function helloWorld() {
    let a = 1;
    if (a === 1) {
        // do something
    } else {
        throw new Error()
    }
}

return helloWorld();

Let me know if you have any questions about that!

1 Like

Thank you

1 Like