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)

Word document from plugin

(0) ShareShare
ReportReport
Posted on by 80

Hi Experts,

Can we create word document from plugin for MSD 365? is it possible? If so how? Done anyone have sample code? 

Thanks. 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    ScottDurow Profile Picture
    21 on at

    Hi!

    There is a action that you can use - see community.dynamics.com/.../how-cool-creating-word-documents-using-a-workflow

    Hope this helps

  • Suggested answer
    Rajkumar Rajaraman Profile Picture
    on at
  • CRM-guy Profile Picture
    80 on at

    I want quote info and its lines based on some condition, but out of the box not working as the i am not able to put any kind of filter there. and thats why i want to create it from plugin with my own query.

  • CRM-guy Profile Picture
    80 on at

    I already know thin and used in couple of times. But I want quote info and its line based on some condition, but out of the box not working as the i am not able to put any kind of filter there. and thats why i want to create it from plugin with my own query.

  • Suggested answer
    Abby Kong Profile Picture
    6 on at

    Hi Vijay,

    Use SetWordTemplate OrganizationRequest

    OrganizationRequest req =
       new OrganizationRequest("SetWordTemplate");
     
    req["Target"] =
       new EntityReference("account", accountGuid);
    req["SelectedTemplate"] =
       new EntityReference("documenttemplate", templateGuid);
     
    service.ExecuteCrmOrganizationRequest(req);

    Check this out:

    https://crmtipoftheday.com/608/generate-documents-in-code/

  • CRM-guy Profile Picture
    80 on at

    Thanks Abby, but will it allow me to change/append the content of the document? Or do i need to replace by some kind of trick?

    Thanks.

  • Abby Kong Profile Picture
    6 on at

    hmmm, can you elaborate on 'change/append the content of the document'??

    The word template should be set up as a system template before you use this code.

    Use the template id from this system template.

    Replace 'new EntityReference("account", accountGuid)' if your entity is not account.

    The generated word document is same as the ones generated from UI ->Ribbon Buttons-> Word Template

  • Abby Kong Profile Picture
    6 on at

    docs.microsoft.com/.../manage-word-templates

    Refer above on creating word templates.

  • CRM-guy Profile Picture
    80 on at

    Hi Abby,

    Thanks for quick responses. See, i am able to create and attach it in notes area of the entity but problem is now i want to add my custom data table in the same Document, is it possible?

    In word template i kept all the required details of the quote, its fine but now i want to fire a query in plugin and I will create a my data table and want to put that in the newly created document. I hope you got my query now. Let me now if you need any other info.

    Thanks.  

  • Abby Kong Profile Picture
    6 on at

    Hi Vijay,

    As far as I know, we can't apply filter/sorting on the data source use word document template. 

    Not sure on the exact requirement, or the number of possible document outputs. If your template is different based on some condition, maybe you can create multiple templates and implement the logic to decide which one to run in the code.

    Alternatively, if you are triggering doc-creating in code, consider the option to create a custom Fetch-based report.

    This is a good guide: community.dynamics.com/.../ssrs-reports-for-dynamics-365-using-fetchxml
    It will be more coding than using word template, but you don't have the above-mentioned restriction on datasource.

    Regards,

    Abby

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