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

SDK Support for File type attributes?

There does not seem to be SDK support for the new File type attributes.


The documentation (here) talks about calling the web service directly when working with these, however the example methods require me to supply 7 parameters including an access token and don't seem to fit a real world example. I am not sure if that code is even achievable inside a plugin.


In addition, none of the tools that use CrmSvcUtil seem to generate a class for a File type attribute. Maybe there is better support in the upcoming release wave though if there is I couldn't find a reference.


I will continue to test eg late binding and accessing the web service inside a plugin or an external app eg a logic app, but would be grateful to hear if others have worked with File attributes in code and how you did it.

2 REPLIES 2
Super User
Super User

Hi @PJ99 

 

I haven't tried it out myself, but I remember seeing blogs where is explained how to work with the file attributes.

Something like this: https://debajmecrm.com/new-data-type-filein-cds-all-you-may-need-to-know-about-it/

Maybe it helps.

 

Kind regards,

Diana

Thanks @DianaBirkelbach - great start thank you.

I was not aware of those SDK messages (InitializeFileBlocksDownloadRequest & InitializeFileBlocksUploadRequest etc) so a really useful post for me and I got the download to work using that. 

Unfortunately his blog has no upload equivalent and I am unable to get this working so obviously I have something wrong.  This is what I tried which executes without exception but no change occurs to the target record/attribute.  This File attribute is such a great CDS feature so I am surprised no-one seems to be using it in code.

private static void UploadFile(CrmServiceClient service, byte[] processedDoc)
{

InitializeFileBlocksUploadRequest req = new InitializeFileBlocksUploadRequest();
req.FileAttributeName = "rss_invoicefile";
req.FileName = "Invoice.docx";
req.Target = new EntityReference("rss_invoice", Guid.Parse("7d14c17f-be9e-ea11-a812-000d3ad20d1c"));

InitializeFileBlocksUploadResponse resp = (InitializeFileBlocksUploadResponse)service.Execute(req);


UploadBlockRequest uploadRequest = new UploadBlockRequest();
uploadRequest.BlockData = processedDoc;
uploadRequest.BlockId = GuidToBase64(Guid.NewGuid());
uploadRequest.FileContinuationToken = resp.FileContinuationToken;

UploadBlockResponse uploadResponse = (UploadBlockResponse)service.Execute(uploadRequest);
Console.WriteLine($"Reponse name: {uploadResponse.ResponseName}");

}

 

kind regards,
Paul

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Users online (69,470)