cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
chris_young
Helper III
Helper III

ForAll within a gallery and Email

All, 

 

I have a gallery, in which I need to send an email to everyone in the gallery. Right now in my test case, I have two records and I do get two emails, but the data within the emails are the same. It is pulling the last record only and sending it twice. 

 

Everything works as far as the SendEmail. The ForAll finds 2 records, but it finds the same record twice, not 1 and 2. Any advice? There will only be 5-10 records max in this gallery at any point in time. It would be possible to select each one and hit the send button, but I'm trying to only have someone hit the send button once for everyone in the gallery. Thank you in advance. 

 

Below is my code

 

ForAll(Gallery7_16.AllItems, Office365Outlook.SendEmail(LookUp(BIS_PMs,'Name (Title)' = Gallery7_16.Selected.'Project Manager'.Value, Email) & ";" & LookUp(BIS_PROJECT, 'Project Name' = Gallery7_16.Selected.Project,'Engagement Manager'.Email),
"BIS Master Data - Employee BIS " & Gallery7_16.Selected.'Resource Name' & " is about to expire.",
"The employee BIS for " & Gallery7_16.Selected.Name & " is about to expire. Please review this employee BIS and resubmit an updated Billing Finish date or allow it to expire on " & Gallery7_16.Selected.'Billing Finish' & ". This person is associated with " & Gallery7_16.Selected.Project & " project, which is related to the " & Gallery7_16.Selected.Customer & " customer."))

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@chris_young 

The issue is that you are referring to the same record regardless of the ForAll.

 

Consider changing your formula to the folllowing:

ForAll(
    Gallery7_16.AllItems, 
    Office365Outlook.SendEmail(
         LookUp(BIS_PMs,'Name (Title)' = 'Project Manager'.Value, Email) & ";" & 
         LookUp(BIS_PROJECT, 'Project Name' = Project,'Engagement Manager'.Email),

         "BIS Master Data - Employee BIS " & 'Resource Name' & " is about to expire.",

         "The employee BIS for " & Name & " is about to expire. Please review this employee BIS and resubmit an updated Billing Finish date or allow it to expire on " & 'Billing Finish' & ". This person is associated with " & Project & " project, which is related to the " & Customer & " customer."
     )
)

 

 I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

3 REPLIES 3
RandyHayes
Super User III
Super User III

@chris_young 

The issue is that you are referring to the same record regardless of the ForAll.

 

Consider changing your formula to the folllowing:

ForAll(
    Gallery7_16.AllItems, 
    Office365Outlook.SendEmail(
         LookUp(BIS_PMs,'Name (Title)' = 'Project Manager'.Value, Email) & ";" & 
         LookUp(BIS_PROJECT, 'Project Name' = Project,'Engagement Manager'.Email),

         "BIS Master Data - Employee BIS " & 'Resource Name' & " is about to expire.",

         "The employee BIS for " & Name & " is about to expire. Please review this employee BIS and resubmit an updated Billing Finish date or allow it to expire on " & 'Billing Finish' & ". This person is associated with " & Project & " project, which is related to the " & Customer & " customer."
     )
)

 

 I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

@RandyHayes 

 

I owe you a burger and beer. Thank you. I see what you did and what I did. It makes sense now why I was getting that error, that .selected killed me. I really appreciate you taking the time to use my data and provide something and it makes perfect sense. Thank you very much. 

@chris_young 

I'll always accept burger and beer!! 😁

No problem at all.  I am glad it was helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (2,693)