web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Generate Document templates using C# batch job

(0) ShareShare
ReportReport
Posted on by 95

We have some word document templates uploaded in CRM,but we have requirement to generate data in these document templates and save that documents in Shared folder

Is there any way to achieve this functionality.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Yes, you will have to write code for that.

  • Suggested answer
    Syed Ibrahim Profile Picture
    6,257 on at

    You can retrieve the template uploaded and generate docs Do the uploaded templates. Pls use the below code to retrieve in your code.

    /////// start///////////////

    var template = (DocumentTemplate)service.Retrieve(DocumentTemplate.EntityLogicalName, {templateId}, new ColumnSet(true));

              var ms = new MemoryStream(Convert.FromBase64String(template.Content));

              var fs = new FileStream("template.docx", FileMode.CreateNew);

              ms.CopyTo(fs);

              fs.Flush();

              fs.Close();

    /////// End ///////////////

    Hope this helps.If the suggestion resolved your query .Pls mark it as answered/verified to close the thread.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans