Hi All,
I am creating a Flow to parse data from Emails.
Can I create a variable which could be accessed from multiple runs of the flow? (like a global variable for all runs during the day)
Use Case:
1) Search email for a keyword and save the number that follows it
2) Save this number in a variable. Concatenate the results for all instances of the keyword
3) Concatenate the results from all such emails for the day
4) Send the concatenated string in an email
I have created the flow which works for one email with multiple instances of the keyword.
Now I would like to concatenate the results from multiple runs of the flow.
Is this possible?
Sample scenario:
Flow 1 runs at 10 AM. Result stored in Flow_result1
Flow 2 runs at 11 AM. Result stored in Flow_result2
Flow 3 runs at 11:30 AM. Result stored in Flow_result3
Can I access Flow_result1 and Flow_result2 when Flow 3 runs?
Please let me know if something is unclear or you need more information to suggest a solution.
Cheers,
Aravind
Solved! Go to Solution.
Your best bet would be storing it in a data source somewhere. Could be an Excel file or SharePoint/Microsoft List. I'd go with SharePoint because that (in my experience) is a bit easier to work with in Power Automate. I'm thinking you'd have a list with two columns: Title (the value to reference) and Date. When the flow runs, it checks the list for any items where Date = the current date; if none are found, it creates an item with Title = the value to store and Date = the current date. If an item is found with the current date, update the Title to add/concatenate the new value to the existing one. If the concatenation of all values could exceed 255 characters, you'd want to use a "multiple lines of text" field to store it. You could have another flow that runs on a schedule (say, just after midnight) to grab the item with the previous day's date (there should only be one) and sends it via email.
Theoretically, this should work, but I'm not sure of your exact use case, so I can't say that there wouldn't be something else that might work better. But, the bottom line is that there's no way for one flow run to reference a variable or value directly from another run of the flow. You need to store the value somewhere neutral (a location that will always be available to the flow) and update/retrieve it as needed.
Here's an analogy that might help: imagine each flow run is a UPS driver. One his route, a driver delivers and picks up packages. Anything he picks up has to go to the UPS depot before it can be delivered to the appropriate recipient. There's no way for driver A to directly deliver a package or hand it off to driver B, even if he knows that's who will deliver it the next day.
Your best bet would be storing it in a data source somewhere. Could be an Excel file or SharePoint/Microsoft List. I'd go with SharePoint because that (in my experience) is a bit easier to work with in Power Automate. I'm thinking you'd have a list with two columns: Title (the value to reference) and Date. When the flow runs, it checks the list for any items where Date = the current date; if none are found, it creates an item with Title = the value to store and Date = the current date. If an item is found with the current date, update the Title to add/concatenate the new value to the existing one. If the concatenation of all values could exceed 255 characters, you'd want to use a "multiple lines of text" field to store it. You could have another flow that runs on a schedule (say, just after midnight) to grab the item with the previous day's date (there should only be one) and sends it via email.
Theoretically, this should work, but I'm not sure of your exact use case, so I can't say that there wouldn't be something else that might work better. But, the bottom line is that there's no way for one flow run to reference a variable or value directly from another run of the flow. You need to store the value somewhere neutral (a location that will always be available to the flow) and update/retrieve it as needed.
Here's an analogy that might help: imagine each flow run is a UPS driver. One his route, a driver delivers and picks up packages. Anything he picks up has to go to the UPS depot before it can be delivered to the appropriate recipient. There's no way for driver A to directly deliver a package or hand it off to driver B, even if he knows that's who will deliver it the next day.
Thanks for your response @ChadVKealey !
Your suggestion makes sense. I had almost decided on the shared excel option but wanted to check if there was a simpler solution. I am now curious to try SharePoint/Microsoft List as per your feedback.
Thanks a lot for explaining in such detail. I believe this should work for my case. Shall update on the results and reach out for any further queries.
Actually, thinking about this a bit more, it might be easier to create one entry in that list for each "update" of the variable/value. That way, you don't have to worry about the length of the data being stored there, plus (for metrics/analytics/troubleshooting) you'll have an individual record of each time the value was stored. If you only need that full concatenation at the end of the day, you'd just get all of the items for that date, use a select to get the title/value column and a join to stick them together. Even if (especially if) this flow will run many times in a day, this will be a more scalable solution. Also, depending on how long you need to keep the data around, that daily flow to send the email could also delete entries that are, for example, more than 30 days old (or 60, 90, 180, etc....whatever fits your retention requirements).