I have used for loop to iterate through every email to check condition I have used if statement…now how to throw an error if subject does not contain “invoice” after iterating through every email
Thank you in advance
I have used for loop to iterate through every email to check condition I have used if statement…now how to throw an error if subject does not contain “invoice” after iterating through every email
Thank you in advance
Hi @Akanksha11 ,
Throwing an Error after finding that the business rule doesn’t meet the requirement, means that You’re exiting from that point of execution.
We would require to know How is the Process Built for this to be answered more flexibly.
For instance if you are using an RE-Framework and List of Emails is the Transaction Data, then in the Process Block you could check for the Condition and Throw a Business Exception, that would let you Skip the Operations for the Current Email and move to the Next Email.
More details on the Process would be helpful for us to suggest better solutions.
When Iterating through For Loop and You encounter an Error we could encapsulate that block with the Try Catch
activity, so that if an Error Occurs/Condition doesn’t match you could use Throw
Activity to Throw an error for that Email, in the Catch
block the error is caught and you could do any operation required for that Error-neous Mail.
This way, the Iteration should continue for the next mail item as well.
Hii see , In try catch block I used get outlook email then in for loop I’m iterating through each loop and then to check condition using if statement if subject doesn’t contain “Invoice” then I’m throwing an exception in else block but its stopping current iteration
Hi @Akanksha11
please follow these steps.
1-get unread mail messages list from mail.
2-loop over mail message list.
3-put condition inside loop.
4- Condition Item.Subject.ToString.Contains(“Invoice”)
5- if the condition is true put all the process in your then block.
6- if mail not contains “Invoice” then put throw activity and put "Email not contains Invoice.
Hi when throw exception in else block current loop breaks I need to complete iteration then need to throw an error
Thanks for replying…
Thanks for replying I have upload the img of my folw
You would need to place a Try Catch
Activity inside the For Each
Activity and then place the Body of the For Each
inside the Try
Block as shown in the image that was posted above by me.
Let us know if you are still facing issues after making the changes.
@Akanksha11 If you want to throw a exception after compilation of every Iteration, so please put bool variable in else and assign false and use that variable where you want to place throw
hi Thank you so much it worked
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.