Monday, November 2, 2026

Add a attchment for docuref

 Scenario :-

I have case where I need to attach base64(huge string which is convert from file) through custom services

>>So in the pam methods I will receive the string .

>> And code to attachment in below

Code:-

Docuref docuref;

 str fileName="test.pdf";

str notes="tesing";

str base64="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

using (System.IO.MemoryStream Stream = new System.IO.MemoryStream(System.Convert::FromBase64String(base64)))

{ 

   docuref=DocumentManagement::attachFile(tableNum(Tablename),Table.RecId,Table.DataAreaId,DocuType::typeFile(),Stream, System.IO.Path::GetFileName(fileName),System.Web.MimeMapping::GetMimeMapping(fileName), System.IO.Path::GetFileNameWithoutExtension(fileName),notes);

}

If you stream file we can directly pass in the above logic.

No comments:

Post a Comment

Custom services in d365fo

 In this blog we see how to develop custom services in d365fo Mainly we need to develop 1) Request class 2) Response class  3) service class...