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

Notifications

Announcements

No record found.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans