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

Switch form based on content of column

(3) ShareShare
ReportReport
Posted on by 6
I have several forms for the Account entity corresponding to the different lines of business that we conduct. In the Account entity I also have a column called "Account Record Type".  I would like to build a solution that looks to the Account Record Type and based on its contents will change to the corresponding form for use with that line of business.  OOTB is preferred but I'm willing to try almost anything since Copilot only provides help for an earlier release of Dynamics CE.
Categories:
I have the same question (0)
  • Suggested answer
    whitebeard Profile Picture
    97 on at

    There is no "Out of the Box" (no-code) configuration to dynamically switch the active form based on a specific column value (like "Account Record Type") in the Unified Interface. Form visibility is typically controlled by Security Roles, but dynamic switching based on data requires JavaScript.

    To achieve this, you must use the formContext.ui.formSelector.navigate() method from the Client API.

    JavaScript Solution
    Create a JavaScript Web Resource with the following function. This code checks the "Account Record Type" and navigates to the correct form if it is not already currently active.
     

    function navigateToFormBasedOnType(executionContext) {
        var formContext = executionContext.getFormContext();
        
        // 1. Get the value of the 'Account Record Type' column
        // Replace 'new_accountrecordtype' with your column's logical name
        var recordType = formContext.getAttribute("new_accountrecordtype") ? formContext.getAttribute("new_accountrecordtype").getValue() : null;
    
        // 2. Define the Target Form ID based on the value
        // You can find the Form ID in the URL when editing the form
        var targetFormId = "";
        
        // Example: Check for specific Choice/OptionSet values (e.g., 100, 101)
        if (recordType === 100) { 
            targetFormId = "00000000-0000-0000-0000-000000000000"; // Insert GUID for Form A
        } else if (recordType === 101) {
            targetFormId = "11111111-1111-1111-1111-111111111111"; // Insert GUID for Form B
        }
        // 3. Navigate only if a target is identified and we are not already there
        if (targetFormId) {
            var currentForm = formContext.ui.formSelector.getCurrentItem();
            if (currentForm.getId().toLowerCase() !== targetFormId.toLowerCase()) {
                var formItem = formContext.ui.formSelector.items.get(targetFormId);
                if (formItem) {
                    formItem.navigate();
                }
            }
        }
    }
     

    Steps:

    1. Web Resource: Upload this script as a JS Web Resource.
    2. Event Registration:
    3. Add this function to the OnLoad event of the Account form.
    4. (Optional) Add this function to the OnChange event of the "Account Record Type" column if you want the form to switch immediately when a user changes the value.
    5. Context: Ensure "Pass execution context as first parameter" is checked in the handler properties.

     

    Hope this helps!

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 120 Super User 2026 Season 1

#2
Jimmy Passeti Profile Picture

Jimmy Passeti 46 Most Valuable Professional

#3
NeerajPawar Profile Picture

NeerajPawar 41

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans