1

I'm writing a custom function in Zoho Flow to perform some writes to Zoho Books from a web hook request.

I want the custom function to FAIL if something goes wrong (for example, if an item cannot be found). I cannot figure out how I can make this function fail. I've scoured the Zoho documentation. Can I not just throw an exception? How do I throw an exception in Deluge?

Side note: I'm sick and tired of Zoho's documentation. I've been using Zoho Books and Analytics for a couple of years now, and it's always SO difficult to find answers.

3 Answers 3

1

You can throw a custom function exception using the throws keyword. Refer to the Deluge script below:

info response;
if(response.get("code") == 0 && isEmpty(response.get("items"))) {
    throws "Items Not Found";
}

Note: The exceptions need to be hardcoded, and variables cannot be used with `throws`.
Sign up to request clarification or add additional context in comments.

1 Comment

its so dumb in deluge they don't make this obvious as a thing to do.
0

You can do a variation on the following example. The example will return "Error at line : 6, Given index 10 is greater than the list size".

If you change the code to in the "Try" block to something that succeeds sometimes then an empty string will be returned on success and a non-empty string will be returned when an exception occurs.

string Throw_Exception()
{
    try
    {
        // change this to the code that should be "tried".
        my_list = List();
        info my_list.get(10);
    }
    catch(err)
    {
        return err;
    }
    return "";
}

Comments

0

In addition to that: I would return a value like "Success" if no error is detected. Following the custom function you can implement a decision based on is not equal to success and proceed the flow as the default. If true you could send a notification with the error.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.