cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bilalsh01
Frequent Visitor

Uploading files to CDS Entity "File" Datatype (filetype)

Hi PowerAppers,

I need to attach 3 files (PDFs) to each record in a CDS entity. I have enabled attachments on the entity. I am also making use of the "File" datatype (filetype) in the CDS entity. I have 3 "File" fields in the entity.

 

Through a form and I am able to upload and attach files to the 3 fields manually with no problems. The trouble is I have thousands of records in the entity and I need an automated way to upload and attach all these files to their corresponding records.

 

I have been experimenting with Power Automation, with no luck. The "Update a Record" action does not expose the "File" datatype fields. I read somewhere that the file attachments are stored in the "Note" entity, but the "File" datatype attachments are not.

 

Can you please help me figure out a practical way to automate this process?

 

Many Thanks

Bilalsh01

1 ACCEPTED SOLUTION

Accepted Solutions

The File data type stores the files in blob storage. They are retrieved from the storage via the API using non-resolvable URLs. 

View solution in original post

13 REPLIES 13
EricRegnier
Super User
Super User

Hi @bilalsh01,

The File type of field is still in preview so the Power Automate functionality for that field might not be all be ready. The only method I know is with Web API or the .NET SDK: https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/file-attributes

You probably need to write some script in .NET or PowerShell to migrate the files...

Hope this helps...

Thank you very much @EricRegnier  for your response. 

 

Yes, I came across this article during my research. I am hoping I can accomplish my mission without having to go the .NET or PowerSell routs because I am not really savvy there.

 

However, I have just figured out how to upload the PDFs to the Attachment of my entity using the Note entity by using an Automation flow. I'm thinking about making a video about this. It took me forever to figure it out. I'm sure others would find it useful.

 

Worst case scenario, I can upload the 3 PDFs to the same record in my entity through the Note entity. 

 

It would be really nice though, to know where the "File" datatype attachments are stored. That would make life a lot easier. I would appreciate it anyone knows.

 

Many Thanks,

Bilalsh01

Yes but attachments in notes activity are not the File field type. How will you move them to the file fields? Or are you planning on having notes attachments for history and file type fields for current and ongoing attachments?

You can use power automate to do this job. Using CDS connector you can upload the files to the entity in the file or image attribute.

Michaelfp_0-1594629468416.png

 

just putting the following json in the content

 

{
"$content-type": "application/pdf",
"$content": "<base 64 string file>"
}

 

I hope that helps you. Please mark as a solution if help you.

The File data type stores the files in blob storage. They are retrieved from the storage via the API using non-resolvable URLs. 

View solution in original post

Thank you all for your help and responses.

 

In light of this,

 

@EricRegnier I think I have no easy choice right now except to keep the files as Note Attachments instead of using the "File" datatype. 

 

@Michaelfp Thank you for your help, I looked into the "Upload file or Image content" action, but I don't have it, I read somewhere that it is only available for USAGovernment.

 

@NHelgren Thanks for the info, now you have put my mind to rest and unfortunately I will have to use the Note Attachments for now until Microsoft provides an easier way to automate uploading to "File" datatype.

 

Thanks again everyone.

Bilalsh01

Make sure to submit your thoughts on bulk uploading Files to Ideas.

It´s not true.

 

I used in many non-USA Government instances. Take a look with you have the correct licenses or your instance is up to date.

Michaelfp,

 

I'm trying to upload email attachments using Flow.  The Flow completes successfully, but when I download the attachment(s) I get an error that reads "Couldn't download - Server problem".  I suspect it is because I did not convert the file to binary.  In your json recommendation, you reference "<base 64 string file>".  Within the context of Outlook attachments, how would I construct the base 64 string file--especially if there are multiple attachments?  

 

Thanks in advance for any assistance you can lend.

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!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

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.

Users online (2,267)