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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Enable/disable document template dynamically

(0) ShareShare
ReportReport
Posted on by
Hi everyone,

I would like to know if there is a way to enable or disable a DocuTemplate dynamically based on a condition, such as a checkbox in a form.
For example, if a user selects a specific option in the UI, the document template should become available or unavailable accordingly. I am looking for a solution that does not require manually removing or re-adding the template but rather controlling its availability dynamically.

The template is not manually created but is installed through an extension of the DocuTemplateRegistrationBase class and the implementation of the LedgerIJournalExcelTemplate interface.

So far, the only workaround I have found is modifying the DocuTemplate record and setting an invalid value in the TemplateType field to prevent the template from being displayed. However, I am unsure if this is a recommended approach or if there is a more standard way to achieve this.

Is there any best practice or alternative solution for this in D365FO? Any guidance or suggestions would be greatly appreciated.

Thanks in advance!
Categories:
I have the same question (0)
  • Suggested answer
    Holly Huffman Profile Picture
    6,530 Super User 2025 Season 2 on at
    Hi there! Good morning, evening, or afternoon - depending on where you are :) Hope you are well today!
     
    To dynamically enable or disable a DocuTemplate in Dynamics 365 Finance and Operations (D365FO) based on a condition (e.g., a checkbox in a form), here are some approaches you can consider:
    1. Use a Custom Field or Flag
    • Add a custom field (e.g., IsTemplateEnabled) to the DocuTemplate table.
    • Update the logic in your extension of the DocuTemplateRegistrationBase class to check this field before making the template available.
    • Example:
      public override boolean isTemplateEnabled()
      {
          return this.DocuTemplate.IsTemplateEnabled;
      }
    • Dynamically update the IsTemplateEnabled field based on the user's selection in the UI.
    2. Modify the Template Availability Logic
    • Extend the LedgerIJournalExcelTemplate interface or the relevant class to include conditional logic for enabling/disabling the template.
    • Use a parameter or a global variable to control the availability of the template.
    3. Leverage Form Event Handlers
    • Use form event handlers to dynamically control the visibility or availability of the template in the UI:
      • Add a checkbox to the form.
      • Use the OnModified event of the checkbox to trigger logic that updates the template's availability.
    4. Avoid Modifying the TemplateType Field
    • While modifying the TemplateType field to an invalid value can prevent the template from being displayed, it is not a recommended approach as it may lead to unintended side effects or maintenance challenges.
    5. Best Practice: Use a Configuration Parameter
    • Create a configuration parameter in System Administration > Setup > Parameters to control the availability of the template.
    • Update the logic in your extension to check the value of this parameter before enabling the template.
    6. Test the Solution
    • After implementing the changes, thoroughly test the solution to ensure that the template's availability is dynamically controlled as expected.
    This approach ensures that the template's availability is managed dynamically without requiring manual intervention or risky workarounds.

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 544 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans