Continue If Error (Append Activity)

Hi Guys,

So I’ve got a for each loop for IDs to run a query - it’s one query and then another query, but only one of them will work with the relevant ID, so in the flow I have one following another, with Continue on Error= True if the Execute query of either ID fails.

I have to append the results to a sheet though, and if the first query is not successful and continuing on error, there is nothing to append, so I am wondering is there a way to continue on error for the append range activity similar to execute query activity.

Or else within an if statement - if the execution is successful, then append - but I can’t get a statement for this IF to work eg: POST_DT.IsNullOrEmpty(POST_DT) ; or something similar.

Any help would be great.

Thanks

1 Like

you can put these activities inside an try-catch block, if any of them fail then you can handle any exception every time it occurs

Hi @Kyleb91,
You won’t get any errors while executing the execute query with an irrelevant ID. Instead of an error you will get an empty datatable as an output. So, by just checking the output datatable row count will help you solve this problem. If rows.count is <=0 then there is nothing to append.

If your execute query fails and doesn’t return any data, then POST_DT is not initialised and it contains NULL reference.

In this case, you can use the following condition -

If POST_DT Is Nothing 
//no data
Else
//data to append

Regards,
Karthik Byggari

1 Like

Hi @Kyleb91

Use execute query and give command as " Select * from dbo_tbl_
and give the datatable as

string.IsNullorEmpty(Post_DT)

else
use write range

Thanks
ashwin S

1 Like

Thanks for all the replies guys, haven’t tried a try catch yet - but this seems to make sense and should work

1 Like

Hi guys - could someone please have a look at this workflow for the above; it doesn’t seem to work - it runs fully when debugged but the IDs in the Variable of ‘EDD_text’ are not running accordingly and appending nothing in my excel.

What I’d like this to do is look in EDD_Text VAR and find the IDs, and then loop through each accordingly depending on what Data script it should be run - in this example, the 123456 should be run for BF. and then the PP IDs should then be attempted to be ran in the scripts and output appended.

Many Thanks_Test2.xaml (81.2 KB)

FYI - I have changed details such as connection strings and IDs etc for security purposes, so all of those are correct in original file

1 Like

Hi

both the approach will work fine together
like the sequence be like this
–use FOR EACH loop and inside the loop use TRY CATCH ACTIVITY only for that query activity and if id is passed for each iteration it will get into the query inside TRY where next to this query activity use a assign activity like this
bool_queryerror = False
where bool_queryerror is a variable of type boolean with default value as False defined in the variable panel
–if that works fine it will go through try block alone
–if that doesnt work it will go to CATCH block where we can use a assign activity like this
bool_queryerror = True

–now next to this TRY CATCH activity, ie., outside to this use a IF condition like this
bool_queryerror = False
if true it will go to THEN part where we can use APPEND RANGE ACTIVITY or goes to ELSE part where we can leave it empty so that it wont append any range to the excel

Cheers @Kyleb91

That’s great man thank you, I will try put this together now.

Have you seen also my latest post earlier, with the attached workflow file?

1 Like

No buddy
I did get chance to see it
Kindly let know for any queries or clarification
Cheers @Kyleb91

Hi guys - could someone please have a look at this workflow for the above; it doesn’t seem to work - it runs fully when debugged but the IDs in the Variable of ‘EDD_text’ are not running accordingly and appending nothing in my excel.

What I’d like this to do is look in EDD_Text VAR and find the IDs, and then loop through each accordingly depending on what Data script it should be run - in this example, the 123456 should be run for BF. and then the PP IDs should then be attempted to be ran in the scripts and output appended.

Many Thanks_Test2.xaml (81.2 KB)

FYI - I have changed details such as connection strings and IDs etc for security purposes, so all of those are correct in original file

Hi Mate, I am having trouble putting together what you have suggested above, could you perhaps edit my flow attached above to emulate your theory?

Much Appreciated!

1 Like

Sure Buddy let me Check once
@Kyleb91

1 Like

Thanks! :))

1 Like

Hey man - any luck? :slight_smile:

1 Like