cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
crjwarre
Helper I
Helper I

Adding a Report from another List to an Email

Hello! Thanks to @mdevaney , I have a form that sends an email to the user when new information is added. This works beautifully, but I am wondering if it would be possible to also add a Report from another List where Lot # = Lot # and then pull the information from that list into the same email. Thank you for your time!!

 

Back(); Set(newRecord, EditForm1.LastSubmit);
Office365Outlook.SendEmail(
	User().Email,
	"Update for Lot# " & newRecord.'Lot #' & "  MBR#" & newRecord.'MBR Number',
	
	"<b>Lot #: </b>"& newRecord.'Lot #'& "<p>" &
	"<b>MBR #: </b>"& newRecord.'MBR Number' & "<p>"&
If(!IsBlank(newRecord.'SKU3 Filled'), "<b>SKU3 Filled: </b>"& newRecord.'SKU3 Filled' & "Units" & "<p>")
, 
    
    {IsHtml: true, Importance: "Normal"}

);

 

1 ACCEPTED SOLUTION

Accepted Solutions

@crjwarre 
Actually, SET is storing the record from the list 'In-Process Issues' in a variable.  We should change the variable name to something else like this.

 

Set(varOtherRecord, LookUp(In-Process Issues, 'Lot #' = newrecord.'Lot #'))

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

13 REPLIES 13
mdevaney
Super User
Super User

@crjwarre 
Yes, you could use a LOOKUP function to retrieve another record from a different list having a matching Lot#.  Place the code directly after where you create newRecord as a variable.

 

Set(otherListRecord, LookUp(your_target_listname, 'Lot #', newRecord.'Lot #'));

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Thank you! I will try this when I'm at work next!

KrishnaV
Super User
Super User

Along with the solution from @mdevaney , I have noticed you are using User().Email this will pulldown the App performance. To avoid that at App onStart property create a global variable as Set(varUser,Office365Users.MyProfileV2()); (include Office365Users to work this). Now in your code say varuser.mail.

which is eventually be as follows:

Office365Outlook.SendEmail(
	varUser.mail,
	"Update for Lot# " & newRecord.'Lot #' & "  MBR#" & newRecord.'MBR Number',
	
	"<b>Lot #: </b>"& newRecord.'Lot #'& "<p>" &
	"<b>MBR #: </b>"& newRecord.'MBR Number' & "<p>"&
If(!IsBlank(newRecord.'SKU3 Filled'), "<b>SKU3 Filled: </b>"& newRecord.'SKU3 Filled' & "Units" & "<p>")
, 
    
    {IsHtml: true, Importance: "Normal"}

);

 

Regards,

Krishna
If this post helps give a 👍 and if it solved your issue consider  Accept it as the solution to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

@KrishnaV 

I do that too, but for a totally different reason.  User().Email is not delegation-friendly when using a FILTER function but Set(varUser, User().Email) is.  So weird...

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Sir,

 

It is the best practice I have read in many of the MVP blogs, as you said user().email is not a delegable in filter this the recommended approach for better performance. Please correct me if you that as a wrong approach. I made it as a practice as I see immense change in performance (on a large Apps).

 

Regards,

Krishna
If this post helps give a 👍 and if it solved your issue consider  Accept it as the solution to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

Ok, so in my case I would list Set(In-Process Issues, LookUp(In-Process Issues, 'Lot #', newRecord.'Lot #')); or would the otherListRecord be the field from the list I want to display? 

 

@mdevaney  

Hello, when I attempt this code, it throws Incompatible Type in the OnStart field for the app

 

@KrishnaV 

@crjwarre
Suggest you use the @ symbol to tell us who you responding to.  There are multiple responders on the thread 🙂

@crjwarre 
I believe there was an error in my previous code 😮  I did not have any comparison in my LOOKUP 😉

 

LookUp(In-Process Issues, 'Lot #' = newRecord.'Lot #');

 

Note: In-Process Issues is assumed to be your "other" list in my example

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (4,361)