Retrieve the module number of the previous module to dynamically refer to values

In my scenario, I want to send an HTTP request to a Microsoft Teams Channel via Webhook.
I create a JSON body as my template message for the Teams Channel.
I want to dynamically set the error message of the module, that failed.
When creating the JSON body template, I do not have access to the error handling route and the specific error message.
Instead of creating the body during each error handling, I would like to refer to the module that was previously executed.

{{errror.message}} provides a null value, as it refers to no information. Only when I fully qualify the variable, e.g. {{1.error.message}} I have the respective error message.

Is there a way to add a placeholder for the “1.”, which will automatically fetch the ID of the previous module?

I saw the below post, and I’m hoping that this may have changed since then.
Get module number - Questions & Answers - Make Community

My idea (create JSON body before the error happens):

The error route (I can either replace the values in the previously created JSON → 3 operations):


The alternative would be to create the JSON in the error handling route and map the values directly (1 operation for each route with error):

Have you tried making all the error paths ending in an unique module an the do the job there? Can’t it be done?

2 Likes

Other solution my be storing the message or error info in a datastore, regardless of which module it occurs in. Later yo could read the datastore registers and make the job of sending the JSON

2 Likes

Hi Ramon,
thanks for the ideas. I doubt that you can “join” error routes together.
They are specific for the module, which goes into error.
I thought about collecting all errors.
The only way that would be possible is to use the “Resume” directive.
Directives for error handling (make.com)

In each error route, I would write the error to an array and add a flow after a router module, which triggers (filter) if the array of errors has elements. I can then send out a message containing all errors.
The problem though is that the scenario will be marked as a success, which is, in my eyes, misleading.

It’s not very nice, but using the function replace in the HTTP module, I can modify the JSON body multiple times.
image

By replacing the values, I have defined previously, I can thus create the complete body with the required error message. Above the free plan, I can even place the JSON body template as a team variable (string) and reduce the operation to create the JSON body during the scenario.

https://www.make.com/en/help/functions/string-functions#replace--text--search-string--replacement-string-

2 Likes

Hi @MarcoMcCarthy welcome to the community :wave:

I just wanted to step in and say congrats on figuring this one out :clap: Also, thanks a lot for jumping back into this thread and sharing your final setup for the benefit of the community. Super helpful and much appreciated :pray:

FYI: I marked your comment as a solution to keep the community organized and easy to look for answers.

2 Likes

One last remark, If you use system variables in the JSON body, they are only set during the scenario execution.
Should you use a custom variable, those values will not be automatically set.
Your “replace” could at the end look something like the following, which I highly doubt anyone trying to maintain your scenario apart from you will be able to understand.
image

2 Likes