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 :
Customer experience | Sales, Customer Insights,...
Answered

Filter available templates in the Export to PDF dialog based on a field value in Dynamics 365

(1) ShareShare
ReportReport
Posted on by 55
Hi everyone,
I have a scenario in Dynamics 365 Sales where I need to control which templates appear in the "Export to PDF" dialog on the Quote entity. When I click on the "Export to PDF" button, it opens a dialog where I can select a Word/PDF template and then choose an action like "Download", "Send as Email", or "Save to OneDrive".
I would like to customize that dialog, or at least influence the list of available templates, so that it is filtered based on the type of Quote (for example, only show templates relevant to a specific "Quote Type" field value).I'm not sure:
What exactly is this dialog (is it a form, a custom page, or something else)?
Can it be accessed or customized through JavaScript, Ribbon Workbench, or another method?
Is there any supported way to dynamically control which templates are available to the user?
I’ve looked into command bar customization using Ribbon Workbench, but I’m not sure if that helps in this scenario.
Any advice or ideas would be greatly appreciated. Thanks in advance!
I have the same question (0)
  • Verified answer
    Daivat Vartak (v-9davar) Profile Picture
    7,835 Super User 2025 Season 2 on at
    Hello dz_ha,
     

    You've hit a common and tricky customization challenge in Dynamics 365 Sales. The "Export to PDF" dialog, while seemingly simple, is a system-controlled component with limited direct customization options. Here's a breakdown of the situation and potential workarounds:

    Understanding the "Export to PDF" Dialog:

    • System Dialog:

      • The "Export to PDF" dialog is a system-generated dialog, not a customizable form or canvas app.
      • It's designed to provide a standard interface for exporting records to PDF using available Word templates. 

    • Template Retrieval:

      • The dialog dynamically retrieves and displays all available Word templates that are associated with the Quote entity.
      • There is no built-in filtering mechanism based on Quote type or other field values. 

      •  

    •  

    Limitations and Challenges:

    • Direct Customization:

      • Direct customization of the "Export to PDF" dialog using JavaScript, Ribbon Workbench, or other standard customization methods is not supported.
      • Microsoft does not expose the dialog's underlying code or provide a supported way to modify its behavior. 

      •  

    •  

    Workarounds and Potential Solutions:

    1. Custom Ribbon Button and JavaScript (Workaround):

      • Concept:

        • Create a custom ribbon button that triggers a JavaScript function.

        • The JavaScript function would:

          • Retrieve the Quote's "Quote Type" value.
          • Dynamically generate a list of relevant Word template IDs based on the "Quote Type".
          • Use the Dynamics 365 Web API to initiate the PDF export process, passing the template ID as a parameter. 

        • This bypasses the standard "Export to PDF" dialog. 

      • Implementation:

        • Use the Ribbon Workbench to create a custom button on the Quote entity's command bar.
        • Attach a JavaScript function to the button's action.
        • Use the Web API's ExportWordTemplateToPDF action to generate the PDF. 

      • Advantages:

        • Provides dynamic template selection based on Quote type.
        • Gives you full control over the export process. 

      • Disadvantages:

        • Requires JavaScript development.
        • More complex implementation.
        • Bypasses the standard dialog's features (email, OneDrive).
        • Requires recreating the Email and Onedrive functionality.

        •  

    2. Power Automate Flow (Alternative):

      • Concept:

        • Create a Power Automate flow that's triggered manually from the Quote record.

        • The flow would:

          • Retrieve the Quote's "Quote Type" value.
          • Retrieve the appropriate Word template ID.
          • Use the "Populate a Microsoft Word template" action to generate the PDF.
          • Send the PDF as an email attachment or save it to OneDrive.

          •  
           

      • Implementation:

        • Create a Power Automate flow with a "When a record is selected" trigger.
        • Use Dataverse actions to retrieve the Quote and template information.
        • Use the Word connector to generate the PDF.
        • Use the Outlook or OneDrive connector to send or save the PDF. 

      • Advantages:

        • No JavaScript development required.
        • Leverages Power Automate's ease of use. 

      • Disadvantages:

        • Manual trigger (not as seamless as a ribbon button).
        • Requires configuring Power Automate connectors.
        • Bypasses the standard dialog's features.

        •  
         

    3. Template Naming Conventions (Simple Workaround):

       

      • Concept:

        • Use clear and consistent naming conventions for your Word templates.
        • Include the "Quote Type" in the template name (e.g., "Quote - Standard," "Quote - Special"). 

      • Advantages:

        • Simple and easy to implement.
        • Requires no development. 

      • Disadvantages:

        • Relies on user awareness and selection.
        • Does not enforce template filtering. 

        •  

    Recommendation:

    • Custom Ribbon Button and JavaScript (Option 1) is the most robust solution. It provides the desired dynamic template selection and gives you full control over the export process.
    • Power Automate (Option 2) is a good alternative if you prefer a no-code approach. However, it requires a manual trigger.
    • Template Naming Conventions (Option 3) is a simple workaround for less complex scenarios.

    •  

    Important Considerations:

    • Testing: Thoroughly test your solution in a non-production environment.
    • User Experience: Design your solution to be user-friendly and intuitive.
    • Maintainability: Choose a solution that's easy to maintain and update.

    •  

    By implementing one of these workarounds, you can achieve dynamic template selection in the "Export to PDF" process, even though direct customization of the dialog is not supported.

     
    If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more. If you have further questions, please feel free to contact me.
     
    My response was crafted with AI assistance and tailored to provide detailed and actionable guidance for your Microsoft Dynamics 365 query.
     
    Regards,
    Daivat Vartak
  • Suggested answer
    Tom_Gioielli Profile Picture
    2,792 Super User 2025 Season 2 on at
    The dialog is system controlled, and unfortunately not editable as far as I am aware. If you are looking to implement this type of functionality, you do have a few options but they are all bypassing the OOB features.
     
    1.  Canvas App or a custom page that is opened from a button on your ribbon. This gives you the greatest flexibility, but it not necessarily a simple thing if you aren't comfortable with PowerFX, Power Automate, and the custom page build process.
    2. Create some custom buttons on your ribbon that call Power Automate flows
     
    Ribbon workbench can help you hide the original button, and create some new button options with attached JavaScript, but it won't let you update the form. This is one of those items where the requested functionality will need to be weighed against the development cost. While you evaluate options, can you get away with simply naming each of the templates with the type of Quote that they relate to so it is clear to users which options are available to choose?
     
    If this answer helped, please consider marking as verified.

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 70 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 33 Most Valuable Professional

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans