I have an email with dynamic information as follows:
There could be any number of quantities of the 3 fields listed above, eg - they could repeat once or 10 times.
What would be the best way to scrape each group of 3 to assign to separate variables? Could we add a quantity field to the email and loop through somehow using Regex and groups? I will then need to use these variables to enter the data into another system and loop through the required amount of times.
Any help would be much appreciated.
Just a quick question before i go into more details, is this a single email with this information in the body?
If so then you can use the email activities to grab the email body and save it in a single string variable. If each second is labeled like you have it, it should be relatively easy to extract with regex groups like you mentioned and set those inside a data table with the columns “title”, “description” and “priority” in a for each loop.
Also a side note if the regex is set up properly you shouldn’t need a quantity variable, it should extract everything that matches the expression like such:
Then you could loop through the regex we get out for each match. If you need any further help when making workflows feel free to reach out!
It will be a single email so I guess that will simplify the process somewhat. I would like to extract each variable in the group of 3 individually, eg Title, Description and Priority. Is this possible using the above method. Also, what would be the best way to pass each group variables into a workflow. For example run 1 will need to enter Title, Description and Priority from group 1. Then loop through to process group 2 etc.
Hopefully this makes sense.
Yes that is possible using this method, you would need three regex expressions each pulling their respective data (title, description and priority) and being saved into three variables. The extractions of the matches are type IEnumberable (similar to an array that you can iterate through). From here you can have a for each loop and have it loop through any of these IEnumerable variables (since they should all be the same length we dont have to worry about which one). Make sure you have a counter variable inside that increments at the end of the loop and in initialized to 0.
Inside of here we will do everything we need to do with each set. For example if we named the regex variables title, description and priority, we would access them like this:
Excellent! Thanks a lot for your help!
Of course! If you need any further help as you develop this workflow feel free to reach out again!
Just trying to build the workflow but struggling a little. Is this the correct order: 1. Assign 3 variables, do a for each look on one of the variables, what about the other 2?. What happens in the “Do” component of the for each please?
How do I then get individual variables for each title, description, priority to pass to the sub workflow and loop through please?
Further to @JosephNehl’s comments - I have built a demo workflow to show you the Regex element. You mentioned earlier it was coming in via a single email. I would look at this video from Anders Jensen as you might be able to get some further inspiration.
Main.xaml (11.4 KB)
I’d populate a data table with it, loop over lines, start new row when you find title, add fields if there is sth new before “:”.
Thanks a lot for the help. The video is definitely of use! For some reason the first activity in your attached .xaml file is producing an error. Any ideas please? Thanks!
You will need to install an official UiPath package:
You will need to go to:
- Manage packages
- Click Official
- Search for “PDF”
- Click Install
- Click OK
Then the activity should be recognised