[Model-driven apps] Deep link a MDA to open on a specific form tab

Mehdi El AmriDyn365CE2 years ago15 Views

Have you ever needed to open a form with a focus on a tab or a section dynamically from a url ? This blog explains in detail an approach to implement this functionality. You’ll need a few lines of JS code, don’t worry the API client will do all the work for us.

Scenario:

We will use the Account table and the standard Account form. The goal is to automatically navigate to an “X” tab by passing his name as a parameter to our URL. For example, the following URL will open an account with a focus on a tab named “DETAILS_TAB”:

https://yourorg.dynamics.com/main.aspx?appid=08d0868e-b4e4-eb11-bacb-000d3a9587a6&pagetype=entityrecord&etn=account&id=7046cbf5-fe9a-ec11-b401-0022486fa9c1&extraqs=tab_name=DETAILS_TAB

How does it work ?

First, we will need to create a Parameter for our form. It can be done within the classic designer:

  • Click on Form Properties
  • Then go to the Parameters tab
  • Add your parameter. In my case, I named it “tab_name”
  • Save & Publish the form

Some JS code will be used to set the focus to a tab Dynamically. The tab’s name will be captured from the URL:

  • Create a JavaScript web resource
  • Implement the logic using the OnLoad Function
  • Register the function in your form
Web Resource Details:
Implementation:
.gist table { margin-bottom: 0; }



This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters



var MEA = window.MEA || {};
var accountForm = MEA.accountForm || {};
(function () {
this.OnLoad = function (onLoadContext) {
var formContext = onLoadContext.getFormContext();
var extraParameters = Xrm.Utility.getGlobalContext().getQueryStringParameters();
var tabName = extraParameters["tab_name"];
if(tabName != undefined){
var defaultTabObj = formContext.ui.tabs.get(tabName);
defaultTabObj.setFocus();
}
};
}).call(accountForm);

view raw

AccountForm.js

hosted with ❤ by GitHub

Event Handler:

All you need is to construct the URL. First, navigate to an account record and copy the URL:

https://yourorg.dynamics.com/main.aspx?appid=08d0868e-b4e4-eb11-bacb-000d3a9587a6&pagetype=entityrecord&etn=account&id=7046cbf5-fe9a-ec11-b401-0022486fa9c1

Then, simply add an extraqs (&extraqs=tab_name=DETAILS_TAB) as below:

https://yourorg.dynamics.com/main.aspx?appid=08d0868e-b4e4-eb11-bacb-000d3a9587a6&pagetype=entityrecord&etn=account&id=7046cbf5-fe9a-ec11-b401-0022486fa9c1&extraqs=tab_name=DETAILS_TAB

The name of the tab can be found easily in the designer. In my case, I used “DETAILS_TAB”:

Hope it helps …

Original Post https://xrmtricks.com/2022/09/12/model-driven-apps-deep-link-a-mda-to-open-on-a-specific-from-tab/

0 Votes: 0 Upvotes, 0 Downvotes (0 Points)

Leave a reply

Join Us
  • X Network2.1K
  • LinkedIn3.8k
  • Bluesky0.5K
Support The Site
Events
March 2025
MTWTFSS
      1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31       
« Feb   Apr »
Follow
Sign In/Sign Up Sidebar Search
Popular Now
Loading

Signing-in 3 seconds...

Signing-up 3 seconds...