cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Ali_Nawaz
Level: Powered On

How to access the Content stored in CDS Attachments

Hello, 

I would like to know how can we access the Content stored in CDS attachements ? 
For intance, I am trying to store a PDF or Image file(Any image file type) in CDS through powerApps and after storing that particular file in CDS I want to access that file through flows/PowerApps and send that stored file as an attchement in E-mail or upload that file on OneDrive. 

Now in CDS, All I can see is just IDs and version numbers.
I have manged to get this Content URI
appres://blobmanager/8964d785a7b04ba89466245be0619629/2
How can I access that uploaded file through this URI and then send it as an attachment in E-mail or Upload it on OneDrive.
I have attached the screenshots of PowerApps and Flows we are using in this case. 

Swift Response is appreciated.

Thank You.
Kind Regards,
Ali Nawaz

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: How to access the Content stored in CDS Attachments

Hi @Ali_Nawaz ,

Do you want to send the uploaded attachment files within your CDS Entity along with an email?

Do you want to use MS Flow to achieve your needs?

 

If you want to use MS Flow to receive the passed Attachment file name and Attachment file content, then send an email/create a file in OneDrive folder, I afraid that Microsoft Flow could not achieve your needs.

The result (appres://blobmanager/8964d785a7b04ba89466245be0619629/2) the First(DataCardValue4_1.Attachments).value formula returns is not valid Binary data, which could be used as the File content within the "Create file" action of your flow.

 

Actually, if you want to send an email with the uploaded file as attachment, you could achieve your needs within your app directly.

When you attach a file to a record using Attachments control within your app, when you edit the record, the uploaded file would be displayed within the Attachments Data card.

I have made a test on my side, please take a try with the following workaround (send an email along with the uploaded file😞7.JPG

within your Edit screen, add a "Send Email" button, set the OnSelect property to following:

Office365.SendEmail(
"Test1@xxxxxx.onmicrosoft.com", /* <-- Email , type your own email address here */
"PowerApps test", /* <-- Subject */
"This is a test", /* <-- Email Body */
{
Attachments: Table({Name: First(DataCardValue9.Attachments).Name, ContentBytes: First(DataCardValue9.Attachments).Value, '@odata.type':""})
}
)

On your side, you should type:

Office365.SendEmail(
                    "Test1@xxxxxx.onmicrosoft.com",   /* <-- Email , type your own email address here */
                    "PowerApps test",                  /* <-- Subject */
                    "This is a test",                /* <-- Email Body */
                    {
                       Attachments: Table({Name: First(DataCardValue4_1.Attachments).Name, ContentBytes: First(DataCardValue4_1.Attachments).Value, '@odata.type':""})
                    }
)

 

If you want to create a file in your OneDrive folder based on the uploaded attachment file, I think you could consider take a try to create a custom connector to achieve your needs.

Please check and see if the following blog video would help in your scenario:

https://repointtechnologies.com/saving-images-from-powerapps-to-sharepoint/

https://www.youtube.com/watch?v=mp-8B1fLrqs&feature=youtu.be

Note: The output format of Add Picture control is same with that of Attachments control, so you could use above solution to achieve your needs.

 

Best regards,

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Community Support Team
Community Support Team

Re: How to access the Content stored in CDS Attachments

Hi @Ali_Nawaz ,

Do you want to send the uploaded attachment files within your CDS Entity along with an email?

Do you want to use MS Flow to achieve your needs?

 

If you want to use MS Flow to receive the passed Attachment file name and Attachment file content, then send an email/create a file in OneDrive folder, I afraid that Microsoft Flow could not achieve your needs.

The result (appres://blobmanager/8964d785a7b04ba89466245be0619629/2) the First(DataCardValue4_1.Attachments).value formula returns is not valid Binary data, which could be used as the File content within the "Create file" action of your flow.

 

Actually, if you want to send an email with the uploaded file as attachment, you could achieve your needs within your app directly.

When you attach a file to a record using Attachments control within your app, when you edit the record, the uploaded file would be displayed within the Attachments Data card.

I have made a test on my side, please take a try with the following workaround (send an email along with the uploaded file😞7.JPG

within your Edit screen, add a "Send Email" button, set the OnSelect property to following:

Office365.SendEmail(
"Test1@xxxxxx.onmicrosoft.com", /* <-- Email , type your own email address here */
"PowerApps test", /* <-- Subject */
"This is a test", /* <-- Email Body */
{
Attachments: Table({Name: First(DataCardValue9.Attachments).Name, ContentBytes: First(DataCardValue9.Attachments).Value, '@odata.type':""})
}
)

On your side, you should type:

Office365.SendEmail(
                    "Test1@xxxxxx.onmicrosoft.com",   /* <-- Email , type your own email address here */
                    "PowerApps test",                  /* <-- Subject */
                    "This is a test",                /* <-- Email Body */
                    {
                       Attachments: Table({Name: First(DataCardValue4_1.Attachments).Name, ContentBytes: First(DataCardValue4_1.Attachments).Value, '@odata.type':""})
                    }
)

 

If you want to create a file in your OneDrive folder based on the uploaded attachment file, I think you could consider take a try to create a custom connector to achieve your needs.

Please check and see if the following blog video would help in your scenario:

https://repointtechnologies.com/saving-images-from-powerapps-to-sharepoint/

https://www.youtube.com/watch?v=mp-8B1fLrqs&feature=youtu.be

Note: The output format of Add Picture control is same with that of Attachments control, so you could use above solution to achieve your needs.

 

Best regards,

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Ali_Nawaz
Level: Powered On

Re: How to access the Content stored in CDS Attachments

Hello Kris Dai,

Bundle of thanks for the solution you mentioned in your last reply, it worked like magic. 
Now there's an issue I'm having with this code. I want to send multiple attachments in Email. 
The solution you provided is working great in case of single attachment but for multiple attachments i am still looking for a workaround. 

I tried to use "For All" function but I received many Errors in it. 
And I also tried to pass collection to Attachments attribute in the SendEmail function of office 365 but got many errors, if you can guide me through with "For All" function or any other workaround it will be highly appreciated. 

Please advise. 

Regards,
Ali Nawaz

Ali_Nawaz
Level: Powered On

Re: How to access the Content stored in CDS Attachments

Hi @v-xida-msft,

 
Let me elaborate it more.

 

I am trying to send multiple attchments (Through CDS attachements ) in Email thourgh Office 365 SendMail function.
When attaching collection in Attachment section of  send email function i am receving an Error. (Find Attched Image)

Blob_error.png

I am also attaching the screenshot of expression I wrote for making a collection (Please see attached image).

Screenshot_1.png
I have followed this tutorial for sending multiple attachments, still no Luck.
https://www.youtube.com/watch?v=V3feURQfY3M

I am hoping for a swift response. 

Regards,
Ali Nawaz

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Users Online
Currently online: 342 members 5,970 guests
Please welcome our newest community members: