cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Apply to each sets variables to null

Hi all,

 

I currently have a model built to examine two pdf attachments (different documents) that arrive via email, I use the predict function to extract the information for the fields in both documents and it pulls all the correct information.

 

I know look to set the information extracted from those documents to variables by using set variable, the only way to do this is to set the variable within the apply to each action due to the predict action. When I look through the set variables for the first attachment, everything is assigned perfectly with the second attachment fields left blank. The issue is when I flip to the second attachment, everything that was assigned is now null except for the fields that are supposed to be extracted from the second attachment. This messes up my flow as now all the variables that were previously set, are now set to null and are incorrect. How do I set up my flow to not set variables to null that have already been set via the first attachment.

 

In other words, is there away to set variables using just the fields in the first attachment and then for just the fields in the second attachment, without overwriting what has already been set?

 

Thanks!

4 REPLIES 4
fchopo
Super User
Super User

Hi @Anonymous 

You can initialize a counter variable outside the apply to each, and then use it in every iteration. If iteration number equals 1, do some assignments, while if it's different, do other ones.

Here's a sample on how to get a numbered iteration: Solved: How to get the numbered iteration in an Apply To E... - Power Platform Community (microsoft.com)

Hope it helps!
Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!
Anonymous
Not applicable

Hi Ferran, thanks for the response. 

 

I am unsure what you mean by using a numbered iteration. Is it essentially setting a variable so that it will only be used for a given attachment? 

 

Please elaborate, still a bit confused after reading the sample you provided.

 

Thanks!

fchopo
Super User
Super User

As I understood, you need to know in which iteration you're, so you can manage first attachment and other attachment. So yes, I'm referring to use a numbered iteration and use that variable to handle attachments.

Hope it makes it clear.

Regards,
Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!
Anonymous
Not applicable

Yes that make sense. The problem I am having is that I do not know how to apply the numbered iteration and only run the model for that given variable.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (1,813)