Catch error node

Hi all

i need to figure out how to avoid the Date&Time difference Node to get reconfigured by itself. Let me explain what is happening. I have a pivoting node before the Date&Time difference node that basically group 2 unique values which each one of the values has a date, then the Date&Time difference Node gets the difference between the dates, however, since i have a loop with many customers and sometimes one of the values with the dates is not found causing the Date&Time difference Node get reconfigured and the loop stops immediately. What node can i use to prevent this to happen?

image

I appreciate your help

Hi @Soldado , I am not sure what you mean by “Date&Time difference Node get reconfigured”. What do you mean reconfigured? Can you give an example?

Regardless, you can use the Try and Catch Errors nodes:

In the Catch Errors node, you can decide what to do in case an error occurs.

3 Likes

Hello @Soldado,

I see what you mean. This is a configuration error which stops workflow execution and unfortunately Try/Catch nodes can’t help as they only catch errors during node execution. But you can try one of following approaches:

  • Table Validator (Reference) node to have expected table structure
  • IF Switch node to skip Date&Time difference node in case there is no Date&Time column in particular loop iteration

Which one you choose depends on your flow but I would probably go with the first one. Give it a try and if any issues/questions feel free to ask.

Br,
Ivan

1 Like

Hello Ivan

i appreciate your help

it seems that Table Validator (Reference) is the one that could work however perhaps i do not know how to configure it.
This is my case:
i have a Pivoting note that comes with this output
image
then Date&Time Difference gets me the difference
image
But there are cases in which there might not be DZ or RV therefore there won’t be a date and when that happens the Date&Time Difference gets reconfigured with the only value that was found and then is when the error occurs, the loop stops.

For instance: in this case the pivoting only gets RV without Date and there is not a DZ column
image
and the Date&Time Difference node chances by itself like this ( 2 RV)
image

when (originally) it has to look like this:

image

i hope i could explain myself

i really appreciate your help

Hello @Soldado,

I get it. So prior to the node where you require certain data structure you have to put Table Validator node. In your case between Pivoting and Date&Time Difference node. Configure it to check column existence and to insert it if missing. Missing values will be inserted to columns which were not present compared to reference data table. I usually use Table Creator to create reference table.

Check this workflow example:

Br,
Ivan

1 Like

You are absolutely correct @ipazin .

I thought that by forcing the Col1 and Col2 of the Date&Time Difference node via flow variables, it would not “reconfigure” and therefore would generate an error - it does force the columns, and therefore does not reconfigure, however, it does not produce an error, but only a warning. So, you are correct, the Try/Catch Error will not be triggered in this case.

Test case:
Note: I don’t have specific data to loop where it will generate different structure, so for the sake of this test, I created 2 separate tables with different structures, and will run them manually separately:
image

Table 1:
image

Table 2:
image

Variable Expressions node returned this:
image

Basically I created 2 variables, DZ has value “DZ” and RV has value “RV”, which I will use to force the Date&Time Difference to use these 2 column names.

Date&Time Difference flow variables configuration:
image

Results for Table 1 (No issue, and same as what @Soldado got):
image

Switching to Table 2:
image

I get warnings, not errors:
image

So, indeed, this will not trigger the Try/Catch Error.

1 Like

Hi Ivan

you are the best, it worked as you said it would.

taking advantage of the forum, is there a way to reset the whole workflow after it was executed?

I appreciate your help

1 Like

Hi Bruno

this solution is amazing too and it is working too.

I appreciate your help

Hi @Soldado , just providing an alternative.

One thing I don’t like about the Table Validator is that it’s kinda restrictive, in the event that you just want to check if a couple of columns exist or not. For example:

  1. If you have let’s say 10 columns, and you only care about 2 columns, you are still checking for 10 columns.
  2. You are restricted to the structure of the reference table, which you may not want. For example, you may get columns in different column order in your case (…, RV, DZ, … vs …, DZ, RV, …). I don’t think that both structures would pass.
  3. In addition to #2 above, even if you have RV, DZ, you may end up with different columns for the different iterations of the loops, since you mentioned that sometimes DZ is not there, so we can assume that may be some other columns might not be there either while both RV and DZ are there. For example:
    ID, Name, DZ, RV, Retired
    ID, Name, DZ, RV, Address

You should be able to calculate the Date difference for these 2 records, but you can’t if you are going to use the same table structure for the Table Validator for both records.

  1. Sure, we can argue that we can do a column filter on DZ and RV, but you actually cannot. Isn’t that the challenge in the first place, to know if DZ and RV exist?

Don’t get me wrong, I am not saying that the Table Validator is bad. It all depends on what you need to do, and given the different cases that you mentioned, and with the assumption that you only care to know if 2 columns exist, just like a hammer is not bad, it has its purpose, but you would not use a hammer to press a pin in a sheet of paper.

So, based on this, I have prepared an alternative, which is simply to check if RV and DZ columns exist, regardless of structure.

Workflow looks like this:

And I tested with the following Data:
Test 1:
image

Results:
image

Test 2:
image

Results:
image

Test 3 (with DZ missing):
image

This time, the IF Switch will route to the bottom:

The Constant Value Column is just adding 0 as Performance:
image

Of course, you can process this case as you want.

Results:
image

Here’s the workflow:
Check if columns exist.knwf (39.7 KB)

4 Likes

Hello @Soldado,

glad you made it work.

Simply close it without saving and it will be in same state as before execution. (Assumption is it is in state reset before execution.)

Br,
Ivan

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.