This is killer. Do you know if there is a way to send only specific attachments related to a record? If I have an opportunity and I attach two documents to it, but then I need to attach two more documents to it and I want only the two most-recently attached documents to be attached to an email, how would I isolate those two attachments in the Flow?
Hey! Thanks for the comment. You could get the most recent document by using the Sort option in the Get by created date. Keep in mind this is looking at the record that links the file to your primary record, so it will return the most recently linked document which might not be the most recently created document. Another approach is to get all files related to your record and then loop through them. This lets you look at each file individually. Because ContentDocumentLink looks up to the file, we can also evaluate fields on the file like its created date and name. In the loop include a Decision with your criteria. If it meets the criteria, go down a path with an assignment step to set a variable to that file's ID and use that variable later in your flow when you send the email. Does that help?
@Rotive Hey thanks very much for the reply! My problem is a bit more complicated now because the files that I'm looking to place in an email are going to be attached to Chatter posts within Opportunity records. The only Chatter object available in a record-triggered flow is Chatter Activity and there doesn't appear to be any way to work with attachments from there.
@@JeremyBrowne-b9i That's tough. I might have to do some experimenting on this. What's the business case? What kinds of files are being posted to chatter and why? Perhaps there is another solution.
@@Rotive So what's happening is our finance team is providing pricing guidance on deals, in the form of two PDF files they give to the opportunity owner to then share with the prospect. The flow they are looking for in Salesforce is for the Finance rep to post attach the PDFs in a chatter post within the Opportunity, that will then send an email to the opportunity owner with the PDFs as attachments in the email. This way the opportunity owner can easily share the attachments with the prospect. As it is currently, the finance rep attaches the PDFs to a chatter post in the opportunity and the opportunity owner receives an alert to the chatter post, but must log into Salesforce to access the attachments. We want to make it more seamless for the opportunity owner to get the PDFs in front of the prospect.
@@Rotive ContentDocumentLink looks up to the file but it does not has an option to evaluate created date and name. I also need to pull only the latest file, but every time time I sorted it it attached ALL the files. Any ideas how to achieve this?
thanks for the video... everything worked well... but what if I want to select a document within few documents... or pick 2 documents among more documents...?
Hey there! Check out my response to @user-tu8lb2jv7w. The key is to have the Get pull back multiple ContentDocumentLinks and then loop through them. You can use a Decision element in the loop to see that particular document matches your criteria, because you can evaluate the name of the file related to the ContentDocumentLink record in the loop
Great video although I seem to be falling into the same errors as many other people... the flow is working I receive an email but the attachment is not included. Has anyone gotten to the bottom of this our found a work around? Any help is appreciated!
Responding to my comment below with the solution! "Great video although I seem to be falling into the same errors as many other people... the flow is working I receive an email but the attachment is not included. Has anyone gotten to the bottom of this our found a work around? Any help is appreciated!" If you have the same issue please read this comment! You must send the "content document link" get records element collection variable through a loop element. In that loop element ADD the current item in the loop to a new resource variable. The resource variable should be - Data type - record -Allow multiple values(collection) - Check - Object = Content Document Link - Available Outside the Flow - available for output In the unofficial salesforce better email action use the newly created resource variable which is described above in the attachments section. Hope this helps save people some time! 😀
Hey Brian, this video is very helpful and very clear to the point. My flow worked and I got the email but there was no attachment. In debug I do see that the file was found. Any idea why this happened.
I would make sure you're getting that Content Document Link ID and not using the Content Document ID accidentally. I've also ran into bugs with this action before. Sometimes you have to delete that step and add it back to fix issues.
This seems like the perfect solution! All seems to be working but for some reason, the attachments appear as a .html file format instead of .pdf or .jpg Does the attachments only link to the Salesforce record for the attachment or is it meant to be the original file format?
Hi Andrew, Thanks for watching! The attachment should be a PDF, jpg, etc. I would double check what ID you're passing into the email action. It might not be correct. Are you finding the same issue with other files you're testing? Maybe this particular file has an issue (size, corruption, weird encoding?)
Hi Brian, I like the better email functionality however, is it possible to do sort of a preview of the images that are attached to a record, then select which ones to attach and attach only those to the email?
I suppose you could in a Screen flow. You'll just need screens ahead of the send email action that lets you review and approve the attachment. Good idea!
It was great solution. But after I installed these two packages, there were no send better email option in my flow action selection box. It's really weird. Do you know what problem of it ?
Thank you for the comment! There are actually three packages you need to install: Flow Actions Base Pack, the Flow Screen Components Base Pack, and then the Send Better Email Package.
You have to use that email template's record ID. You'll find it in the URL if you have the template record open. I've also ran into bugs with this sometimes. I would try deleting the element and then adding it back to the flow. Also, if you don't need the attachment functionality, consider using the default Send Email action. It now accepts email templates since a recent update.
Hi Brian, thanks for your useful video. I want to get all files from the opportunity record and the most recent file from a related account with type 'x'. I can't find a way to include that logic in your 'Get File' component. Can you propose a solution for that? Regards, Freek
Hey Freek, I haven't used this action to send more than just 1 attachment at a time. You'll need to create a collection: either a record collection, or more likely a text collection with the IDs of all those Content Document Links. This one is tricky to explain over text. Consider joining our membership. This is the kind of thing we can walk through during Office Hours.
Thanks for sharing Brian. Quick question. How can I give management confidence in downloading something into our Org that is not on the app exchange? Could there be any security concerns with downloading something from UnofficialSF? Thanks again!
Good question. Yes, there is a risk in downloading and running anything off UnofficialSF. It hasn't been reviewed by Salesforce's security team. Much of this code is publicly visible on Github but that's no guarantee. It's a reasonable concern.
In the Get Content Document Link step, you can sort the get by Created Date and make it Descending. Then have the Get only return one record instead of all of them. This will return you the most recently created Content Document Link. This is the most recently added file, maybe not the newest file in the system.
Hi, Thank you for the video, I was able to attach the files needed, but I am having an issue with the email template working. I have tried many times to get this to work, read the pages, etc. and its not working with merge fields. What am I missing? Thank you!!
Hey Kate, I've run into issues with the Send Better Email component before that I couldn't figure out. I would try deleting the component from your flow and adding it again and filling out the values again. It might be a bug if you're confident you have the right template id or template api name included.
The standard upload file component in a screen flow adds that file to a record once you progress to the next screen. It should provide the ID of the newly created Salesforce file for your use in the Flow automatically. Screen flow is a good option here.
How to use the tool above to get report file from Report? I want to send a daily report as attachment to outbound email (the receiver is does not have Salesforce license to subscribe daily report)
Is there a way to create a CSV file and then send it in Flow? In this case the file doesn't exist in Salesforce, so I can't reference a Content Document id.
Hey Cassi, check out this Flow Action: unofficialsf.com/enhanced-generate-csv-file-from-record-collection-action/ I haven't tried it yet. Please let me know if works for you. This could be a great solution for people that need to send data to colleagues or partners outside of Salesforce.
Hi Brian, how are you doing? Do you know if the organization needs settings for the attachment? My email is sending, but without the attachment. In the Debug, the File is getting correct, but doesn't send. I adjusted the attachment size in the org settings to the maximum, but it doesn't work yet. Help me guyssss
Now that I think about it. Try deleted the Send Better Email action and adding it again. I've run into bugs without before. Deleting and adding it back have helped. Make sure you know all the values you need, because you'll have to set them again.
Has anyone had the problem of the email not attaching more than one file? I. E. collection with only one entry will attach and send, more than that will not attach. The user debugging the flow is admin, so I am at a loss of if it is some sort of permission limitation or malformtion of the outputs.
Hey, this shouldn't be a permissions issue. It's possible that you're using a Record Collection and not a Text Variable Collection. I'm not 100% sure, but I bet you need to use the latter. Once you get all those Content Document Links, loop through them adding the ID of each one to a text variable collection. Then reference your text variable in the action.
This looks great but it makes me think that won't it be internally calling the apex Messaging class??? This defeats the whole purpose of using flow cause it will hit the 5000 daily limit through apex
Hey there! You are right, the standard 5000 email limit would still apply since we're sending the email from Salesforce's servers. Are you running into that limit? Have you asked Salesforce to raise the limit for you? Worth submitting a case to see if they'll do it.
Hey Nick, Check out my response below to @user-tu8lb2jv7w. Please reply there with any questions, we can keep one thread to help future viewers. Thanks for watching!
@@Rotive Does this mean that the email can be sent even if there is not an attachment. I ask because I have a use case where some people will attach files but others will not. It would be great to just use one email.
Has anyone had the problem of the email not attaching more than one file? I. E. collection with only one entry will attach and send, more than that will not attach. The user debugging the flow is admin, so I am at a loss of if it is some sort of permission limitation or malformtion of the outputs.
Great video however for some reason when the email is delivered there is no attachment. I browsed through the documentation and I am not sure I fall under any of the troubleshooting. When I debug I see it is pulling the content ContentDocumentLink because I see the id and if i add another document I see the second id. I thought maybe my Spam filter dropped the attachment so I tried other emails, still no attachment? any ideas??
That is interesting... You've already checked debug, which is where I would start and see those IDs. Could it be the type of file? What if you try some different records and files? Perhaps the attachment is too big or it's an unsupported file type.
Mind blowing solution!! My recent favorite Salesforce channel!!
Thanks! That's nice very nice of you.
This is killer. Do you know if there is a way to send only specific attachments related to a record? If I have an opportunity and I attach two documents to it, but then I need to attach two more documents to it and I want only the two most-recently attached documents to be attached to an email, how would I isolate those two attachments in the Flow?
Hey! Thanks for the comment. You could get the most recent document by using the Sort option in the Get by created date. Keep in mind this is looking at the record that links the file to your primary record, so it will return the most recently linked document which might not be the most recently created document.
Another approach is to get all files related to your record and then loop through them. This lets you look at each file individually. Because ContentDocumentLink looks up to the file, we can also evaluate fields on the file like its created date and name. In the loop include a Decision with your criteria. If it meets the criteria, go down a path with an assignment step to set a variable to that file's ID and use that variable later in your flow when you send the email.
Does that help?
@Rotive Hey thanks very much for the reply! My problem is a bit more complicated now because the files that I'm looking to place in an email are going to be attached to Chatter posts within Opportunity records. The only Chatter object available in a record-triggered flow is Chatter Activity and there doesn't appear to be any way to work with attachments from there.
@@JeremyBrowne-b9i That's tough. I might have to do some experimenting on this. What's the business case? What kinds of files are being posted to chatter and why? Perhaps there is another solution.
@@Rotive So what's happening is our finance team is providing pricing guidance on deals, in the form of two PDF files they give to the opportunity owner to then share with the prospect. The flow they are looking for in Salesforce is for the Finance rep to post attach the PDFs in a chatter post within the Opportunity, that will then send an email to the opportunity owner with the PDFs as attachments in the email. This way the opportunity owner can easily share the attachments with the prospect. As it is currently, the finance rep attaches the PDFs to a chatter post in the opportunity and the opportunity owner receives an alert to the chatter post, but must log into Salesforce to access the attachments. We want to make it more seamless for the opportunity owner to get the PDFs in front of the prospect.
@@Rotive ContentDocumentLink looks up to the file but it does not has an option to evaluate created date and name. I also need to pull only the latest file, but every time time I sorted it it attached ALL the files. Any ideas how to achieve this?
Hi Brian, thanks a lot for this video, that is super useful! is there a way to allow the user to choose which file he wants to send via a screen flow?
thanks for the video... everything worked well... but what if I want to select a document within few documents... or pick 2 documents among more documents...?
Great Question. We are wondering the same thing
Hey there! Check out my response to @user-tu8lb2jv7w. The key is to have the Get pull back multiple ContentDocumentLinks and then loop through them. You can use a Decision element in the loop to see that particular document matches your criteria, because you can evaluate the name of the file related to the ContentDocumentLink record in the loop
I hve many times this concept pratics but result is always fail.... Then i watch u r video last 2hr back and finally done 👌🏻🥳🙏🎉 thanxs brian. ❤️
Glad it helped!
Thank you for sharing.
Will it consume the Apex email daily limit?
because I have seen apex email somewhere in the flow.
I do think this will count against your daily Salesforce email limit of 5000.
Incredible!!! Thanks for sharing!!
Great video although I seem to be falling into the same errors as many other people... the flow is working I receive an email but the attachment is not included. Has anyone gotten to the bottom of this our found a work around? Any help is appreciated!
Thank you so much Brian. This solved a big challenge for me!
Glad it helped! Thank you for the comment, Charlie.
this is great. Please do the same but with bulk email functionality.
Thanks for the comment! We'll add that video idea to our list. Appreciate it!
Responding to my comment below with the solution!
"Great video although I seem to be falling into the same errors as many other people... the flow is working I receive an email but the attachment is not included. Has anyone gotten to the bottom of this our found a work around? Any help is appreciated!"
If you have the same issue please read this comment!
You must send the "content document link" get records element collection variable through a loop element. In that loop element ADD the current item in the loop to a new resource variable. The resource variable should be
- Data type - record
-Allow multiple values(collection) - Check
- Object = Content Document Link
- Available Outside the Flow - available for output
In the unofficial salesforce better email action use the newly created resource variable which is described above in the attachments section. Hope this helps save people some time! 😀
Hello Brian,
I searched for the better email option but it’s not there in actions. :/
Hey Brian, this video is very helpful and very clear to the point. My flow worked and I got the email but there was no attachment. In debug I do see that the file was found. Any idea why this happened.
I would make sure you're getting that Content Document Link ID and not using the Content Document ID accidentally. I've also ran into bugs with this action before. Sometimes you have to delete that step and add it back to fix issues.
This seems like the perfect solution! All seems to be working but for some reason, the attachments appear as a .html file format instead of .pdf or .jpg
Does the attachments only link to the Salesforce record for the attachment or is it meant to be the original file format?
Hi Andrew, Thanks for watching!
The attachment should be a PDF, jpg, etc. I would double check what ID you're passing into the email action. It might not be correct. Are you finding the same issue with other files you're testing? Maybe this particular file has an issue (size, corruption, weird encoding?)
What a great video, Brian! Thank you. I love your channel.
Thank you, Anna!
This is incredibly helpful! Thanks so much Brian!
Glad it was helpful!
Hi Brian,
I like the better email functionality however, is it possible to do sort of a preview of the images that are attached to a record, then select which ones to attach and attach only those to the email?
I suppose you could in a Screen flow. You'll just need screens ahead of the send email action that lets you review and approve the attachment. Good idea!
It was great solution. But after I installed these two packages, there were no send better email option in my flow action selection box. It's really weird. Do you know what problem of it ?
Thank you for the comment! There are actually three packages you need to install: Flow Actions Base Pack, the Flow Screen Components Base Pack, and then the Send Better Email Package.
Such a great and usefull video! Many thanks for this!
Glad it was helpful, Christian!
Hi Brian, Great Video. Can you please explain how to add an email template? for some reasons I cannot link between the two. Thank you!
You have to use that email template's record ID. You'll find it in the URL if you have the template record open. I've also ran into bugs with this sometimes. I would try deleting the element and then adding it back to the flow.
Also, if you don't need the attachment functionality, consider using the default Send Email action. It now accepts email templates since a recent update.
Hi Brian, thanks for your useful video. I want to get all files from the opportunity record and the most recent file from a related account with type 'x'. I can't find a way to include that logic in your 'Get File' component. Can you propose a solution for that? Regards, Freek
Hey Freek, I haven't used this action to send more than just 1 attachment at a time. You'll need to create a collection: either a record collection, or more likely a text collection with the IDs of all those Content Document Links. This one is tricky to explain over text. Consider joining our membership. This is the kind of thing we can walk through during Office Hours.
Thanks for sharing Brian. Quick question. How can I give management confidence in downloading something into our Org that is not on the app exchange? Could there be any security concerns with downloading something from UnofficialSF? Thanks again!
Good question. Yes, there is a risk in downloading and running anything off UnofficialSF. It hasn't been reviewed by Salesforce's security team. Much of this code is publicly visible on Github but that's no guarantee. It's a reasonable concern.
Is there a way to configure so I will grab the most recent created attachment?
In the Get Content Document Link step, you can sort the get by Created Date and make it Descending. Then have the Get only return one record instead of all of them. This will return you the most recently created Content Document Link. This is the most recently added file, maybe not the newest file in the system.
Hi, Thank you for the video, I was able to attach the files needed, but I am having an issue with the email template working. I have tried many times to get this to work, read the pages, etc. and its not working with merge fields. What am I missing?
Thank you!!
Hey Kate, I've run into issues with the Send Better Email component before that I couldn't figure out. I would try deleting the component from your flow and adding it again and filling out the values again. It might be a bug if you're confident you have the right template id or template api name included.
This is not working for me. It does not recognize my Get File action. It just says no data. Any idea why this might be?
Hi, I am trying to attach the files by taking the input from the user? Is screen flow the best for that and how do I call those files in my flow
The standard upload file component in a screen flow adds that file to a record once you progress to the next screen. It should provide the ID of the newly created Salesforce file for your use in the Flow automatically. Screen flow is a good option here.
How to use the tool above to get report file from Report? I want to send a daily report as attachment to outbound email (the receiver is does not have Salesforce license to subscribe daily report)
Hey there, I think this video will help you out: th-cam.com/video/WfOAkDVM7DU/w-d-xo.html
Is there a way to create a CSV file and then send it in Flow?
In this case the file doesn't exist in Salesforce, so I can't reference a Content Document id.
Hey Cassi, check out this Flow Action: unofficialsf.com/enhanced-generate-csv-file-from-record-collection-action/ I haven't tried it yet. Please let me know if works for you. This could be a great solution for people that need to send data to colleagues or partners outside of Salesforce.
Hi Brian, how are you doing? Do you know if the organization needs settings for the attachment? My email is sending, but without the attachment. In the Debug, the File is getting correct, but doesn't send. I adjusted the attachment size in the org settings to the maximum, but it doesn't work yet. Help me guyssss
Hey Paulo, I'm really good. Thanks! I haven't run into a size issue, but that's a good thought. To troubleshoot, I'd use a small file. Any luck?
Now that I think about it. Try deleted the Send Better Email action and adding it again. I've run into bugs without before. Deleting and adding it back have helped. Make sure you know all the values you need, because you'll have to set them again.
Has anyone had the problem of the email not attaching more than one file? I. E. collection with only one entry will attach and send, more than that will not attach. The user debugging the flow is admin, so I am at a loss of if it is some sort of permission limitation or malformtion of the outputs.
Hey, this shouldn't be a permissions issue. It's possible that you're using a Record Collection and not a Text Variable Collection. I'm not 100% sure, but I bet you need to use the latter. Once you get all those Content Document Links, loop through them adding the ID of each one to a text variable collection. Then reference your text variable in the action.
Followed the instructions, but every time I try to use it in a flow, I get an error and it will not save the flow.
Can you tell me what the error says?
This looks great but it makes me think that won't it be internally calling the apex Messaging class??? This defeats the whole purpose of using flow cause it will hit the 5000 daily limit through apex
Hey there! You are right, the standard 5000 email limit would still apply since we're sending the email from Salesforce's servers. Are you running into that limit? Have you asked Salesforce to raise the limit for you? Worth submitting a case to see if they'll do it.
@@Rotive Does they charge additionally for increasing the limit? We run on the performance edition
Has anybody figured out how to sort which file you want to send? I have multiple files but only want to send one.
Hey Nick, Check out my response below to @user-tu8lb2jv7w. Please reply there with any questions, we can keep one thread to help future viewers. Thanks for watching!
Usefull
Glad you think so!
Email receives But Without Attachment
You'll have to dig into the debug log to see if the file exits/the Get is finding it.
@@Rotive Does this mean that the email can be sent even if there is not an attachment. I ask because I have a use case where some people will attach files but others will not. It would be great to just use one email.
Has anyone had the problem of the email not attaching more than one file? I. E. collection with only one entry will attach and send, more than that will not attach. The user debugging the flow is admin, so I am at a loss of if it is some sort of permission limitation or malformtion of the outputs.
This doesn't not work with opportunities.
Object should matter. The principle is the same, though perhaps there are permission issues.
Great video however for some reason when the email is delivered there is no attachment. I browsed through the documentation and I am not sure I fall under any of the troubleshooting.
When I debug I see it is pulling the content ContentDocumentLink because I see the id and if i add another document I see the second id. I thought maybe my Spam filter dropped the attachment so I tried other emails, still no attachment? any ideas??
That is interesting... You've already checked debug, which is where I would start and see those IDs. Could it be the type of file? What if you try some different records and files? Perhaps the attachment is too big or it's an unsupported file type.
@@Rotive PDF I am looking into documentation regarding the sharing of files.