I want to retrieve a record from Knack using its ID.
What is the problem & what have you tried?
For whatever reason, sometimes the record takes time to show up in Knack’s API, so when my scenario runs, there have been cases where Knack’s “Get a record” returns an empty bundle, but does not error. The scenario continues until another module needs the record’s data, and errors when it finds out there isn’t any. Automatic retries don’t work in this case because the scenario can’t roll back to re-run already executed modules.
This makes it difficult to implement retry logic for this Knack module, and I think it would be sensible for this particular Knack module to error if the requested record does not exist.
Is there any way to trigger an error at will based on the output of another module, and then be able to retry said module? I guess I could clone all modules of my scenario and route based on the output of the Knack module, but I would really want to avoid this scenario, because it is not really a robust or scalable solution.
Error messages or input/output bundles
When querying for a record with an ID that doesn’t exist, the module executes successfully and returns nothing:
add a router after the Knack module. On the main route add a filter that only allows it to continue if the record was found.
On the second route you can either force an error with a parse a JSON module for example.
But if the issue is timing, then you can add a sleep module followed by another Knack module to try and retrieve the record say after a five minute delay (or however long it usually takes).
To add on what @Stoyan_Vatov already mentioned, you can avoid consuming unnecessary credits by filtering on whether the bundle returned by the Knack module is empty or not. See the image below:
I would go with one of the three solutions discussed on this thread:
You just add a router with filters to check if the result exists, then sleep for N seconds and retry the knack module.
You reschedule the scenario interval based on the result.
You add the knack module to a sub scenario and force an error if its result is empty. Then, on the parent scenario, add a break directive to retry from that point on.
I prefer option #3 and I believe that’s what you asked for in the first place.