cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JGotta
Regular Visitor

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 @JGotta 

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....

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!
JGotta
Regular Visitor

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!
JGotta
Regular Visitor

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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (3,717)