Friday, May 24, 2019

Download/Edit existing word template from Dynamics 365

Download/Edit existing word template from Dynamics 365

There is no direct ways to download the existing download template in Dynamics CRM. In order to do that it we can do it from SDK code.


            Guid templateId = new Guid("3AE567D9-BEB5-E711-8147-E0071B6AE051");
            Entity objDocTemplate = objService.Retrieve("documenttemplate", templateId, new ColumnSet(true));

            if (objDocTemplate != null && objDocTemplate.Attributes.Contains("content"))
            {
                var ms = new MemoryStream(Convert.FromBase64String(objDocTemplate["content"].ToString()));
                var fs = new FileStream(@"C:\LOAWordTemplate.docx", FileMode.CreateNew);
                ms.CopyTo(fs);
                fs.Flush();
                fs.Close();
            }

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.