Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Change tab focus based on field change

(0) ShareShare
ReportReport
Posted on by 49
We have a business requirement on the case form to change the tab focus when a specific field changes... The catch is this field is on a contact form that we are using the built in control to display on the case form.  I have this code but I am unsure how we can get the code to read to the case form when the contact field is modified... Any help would be greatly appreciated! Thank you!
 
function FocusOnTab(executionContext) {
    var formContext = executionContext.getFormContext();
    formContext.ui.tabs.get(/general/).setFocus();
}
  • RudyZhang Profile Picture
    Microsoft Employee on at
    Change tab focus based on field change
    Hi,
     
    Regarding your request to change the focus of a tab when a specific field is changed
     
    Our team has analyzed your requirement and here is our understanding of the problem: There are two forms, FormA and Form B. FormB is displayed on FormA using built-in controls, and when a field in FormB is changed, the tab focus of FormA changes.
     
    The following is the modified code of our team
    function onChangeField() {
        var formA = Xrm.Page.ui.formSelector.getCurrentItem(); // Get the currently selected FormA
        var tabB = formA.tabs.get("tabB_name"); // Replace with the actual Tab B name
    
        if (tabB) {
            tabB.setFocus();
        }
    }
    
    In addition, you need to use the code by following these steps
     
    Step1, open Dynamics 365 and navigate to the design screen of FormB.
    Step 2: Locate the specific field you want to modify and select it. In the field's property settings, look for the "Events" option.
    Step 3: In "Events", find the "OnChange" event and add the above JavaScript event handler.
    Step 4: Save and publish the changes to FormB.
     
    Note, please make sure you replace "tabB_name" in the code with the actual Tab B name, which is the name of the tab you want to switch to.
     
    I hope my answer is helpful to you! If you have any other questions, please feel free to contact me.
     
    Best Regards,
    Rudy Zhang
     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,323 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,193 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans