Error message from Loop End with Empty Table Switch

Hello, I’m running into an error message from the Loop End node when using the Empty Table Switch and I was wondering if anyone had advice on how to fix it.

I originally had a workflow like the screenshot below. It worked as expected - each file was read in, converted to JSON, the JSON fields were selected and some basic data munging was done, and then it output two separate .csv files.

Then I needed to filter on one of the values in the fields, so I added a Row Filter and an Empty Table Switch:

If the field has that value, the row should be skipped and the next file should be read instead.

Running this version of the workflow breaks at the Loop End node with the message “Active Scope End node in inactive branch not allowed.”

I’m not sure what this error is trying to indicate and have tried several alternate approaches but haven’t found any way to do what I need to. Does anyone have a suggestion on a different approach to take, or a way to fix this one?

Thanks for taking a look!

Hi @J_U ,

The specific error is because your Empty Table Switch has to be completed (with an End If or Case Switch End node) before the Loop End, because otherwise, in the event of the table being empty, the branch that is attached to the Loop End becomes “inactive” and that isn’t allowed.

e.g.

In it’s simplest form it would look like this:

In your case, you have two branches to be undertaken on a non-empty-table but you have specified nothing for the empty condition. To wire that up with valid branch terminations, you could do this:

BUT… Is the Empty Table Switch necessary?

It might be, it might not… :wink:

In the event that the table is empty, do the columns specified by Column Renamer and Column Resorter not exist? If so, I can see why you need to branch, but if the columns are always present, does it work anyway without the presence of the Empty Table Switch?

An Empty Table should not in itself prevent the loop continuing, and should have no effect on the output from the loop, since an empty table does not add any rows to the output. It is (in effect) “skipped”, which is why I wonder if you need the Empty Table Switch at all…

What happens if you simply leave in the Row Filter but remove the Empty Table Switch? Does the loop not complete?

2 Likes

Thanks @takbb! This solution worked perfectly. I hadn’t realized the End If node was the terminator for anything besides the IF Switch.

And to answer your question, yes, if the table is empty, the columns specified by Column Renamer and Column Resorter do not exist.

I appreciate your help - cheers!

1 Like

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