{"id":510,"date":"2023-06-28T08:01:00","date_gmt":"2023-06-28T08:01:00","guid":{"rendered":"https:\/\/automatethemundane.com\/index.php\/2023\/03\/07\/deep-link-to-a-specific-tab-in-a-model-driven-app\/"},"modified":"2023-07-04T14:34:23","modified_gmt":"2023-07-04T14:34:23","slug":"deep-link-to-a-specific-tab-in-a-model-driven-app","status":"publish","type":"post","link":"https:\/\/automatethemundane.com\/index.php\/2023\/06\/28\/deep-link-to-a-specific-tab-in-a-model-driven-app\/","title":{"rendered":"Deep Link to a specific tab in a Model Driven app"},"content":{"rendered":"\n<p class=\"has-text-color\" style=\"color:rgba(120, 119, 116, 1)\">6\/28\/2023<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">The Why<\/h1>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">At times, certain users may need to be directed to a specific tab when they are sent a link in an email. This solution builds off of the existing tab code from <a href=\"https:\/\/automatethemundane.com\/index.php\/2023\/02\/24\/expanding-model-driven-apps-with-code-hiding-tabs-until-record-is-created\/\" data-type=\"post\" data-id=\"498\" target=\"_blank\" rel=\"noreferrer noopener\">Expanding Model Driven apps with code - Hiding Tabs until record is created<\/a>. In this scenario, new users of the app will be sent an email that directs them directly to the Documentation tab.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">The How<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">Create Parmenter<\/h2>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">From the form select switch to classic. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2023\/06\/image-51-1024x152.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">Select Form Properties<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2023\/06\/image-52-1024x359.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">Create the Parmenter as follows<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2023\/06\/image-53.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">Save and Publish the changes once completed. <\/p>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">Back at the form designer ensure the documentation tab is named \u201ctab_documentation\u201d<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2023\/06\/image-54-1024x489.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-background\" style=\"background-color:rgb(241, 241, 239)\">\ud83d\udca1 Note: you may need to select \u201cShow Hidden\u201d to display the tab. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Code<\/h2>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">We will be creating another code block that will work alongside the the code used in the  with the following<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var MEA = window.MEA || {};\nvar Form = MEA.Form || {};\n\n(function () {\n    this.OnLoad = function (onLoadContext) {\n        var formContext = onLoadContext.getFormContext();\n        var extraParameters = Xrm.Utility.getGlobalContext().getQueryStringParameters();\n        var tabName = extraParameters&#91;\"tab_name\"];\n        if(tabName != undefined){\n            var defaultTabObj = formContext.ui.tabs.get(tabName);\n            defaultTabObj.setFocus();\n        }\n    };\n}).call(Form);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Add Code into the solution<\/h2>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">From the solution add the new javascript and name it tabcontrol-documentation<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2023\/06\/untitled-75-1024x496.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">In the form add a new On Load event<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2023\/06\/untitled-76.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Testing Link<\/h2>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">Navigate to a record in the app and copy the URL. Add the following to the end of the URL. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&amp;extraqs=tab_name=tab_documentation<\/code><\/pre>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">The entire URL should now look like this. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;ORGID.crm.dynamics.com\/main.aspx?appid=APPID&amp;pagetype=entityrecord&amp;etn=TABLENAME&amp;id=ROWID&amp;extraqs=tab_name=tab_documentation<\/code><\/pre>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">Copy and paste the URL into your browser and ensure that it goes to the correct tab. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Create Flow<\/h2>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">With the code working we will now need to send an email with the correct link. <\/p>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">Within the solution create a Power Automate flow that will send a notification email to the supervisor when a new record is created. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2023\/06\/untitled-77-1024x658.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgba(120, 119, 116, 1)\">\ud83d\udca1 My Flow name is \u201cPurchase Request Flow 1.1- Send Supervisor link to Request\u201d<\/p>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">I am a big fan of Scope in Power Automate. It helps me keep flows looking clean and troubleshoot when a clow gets complicated. <\/p>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">This flow though is very simple. When a new request is made, Automate looks up the supervisors email, generates the URL, then sends it to the supervisor in an email. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2023\/06\/untitled-78.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Supervisor<\/h2>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">To get the supervisors email, I did a lookup to the users table and used the supervisor_value as the ID. <\/p>\n\n\n\n<p class=\"has-background\" style=\"background-color:rgb(241, 241, 239)\">\ud83d\udca1 This could be taken down to one step, but I like to break them out for visualization purposes. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2023\/06\/untitled-79.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">URL<\/h2>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">Building the URL is fairly straightforward, the first three items are all hardcoded to my environment. The last one puts them all together in the proper format. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2023\/06\/untitled-80.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Email<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2023\/06\/untitled-81.png\" alt=\"\"\/><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\">Conclusion<\/h1>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">The next steps would be to make the email look better and format the URL so that it is friendly to the user getting the email. However, that will be a post for another day. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>6\/28\/2023 The Why At times, certain users may need to be directed to a specific tab when they are sent a link in an email. This solution builds off of the existing tab code from Expanding Model Driven apps with code &#8211; Hiding Tabs until record is created. In this scenario, new users of the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":490,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[31,39,4,29],"class_list":["post-510","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-model-driven-app","tag-forms","tag-javascript","tag-mda","tag-power-automate","entry","has-media"],"jetpack_featured_media_url":"https:\/\/automatethemundane.com\/wp-content\/uploads\/2023\/06\/photo-1605701250441-2bfa95839417-scaled.jpg","_links":{"self":[{"href":"https:\/\/automatethemundane.com\/index.php\/wp-json\/wp\/v2\/posts\/510","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/automatethemundane.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/automatethemundane.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/automatethemundane.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/automatethemundane.com\/index.php\/wp-json\/wp\/v2\/comments?post=510"}],"version-history":[{"count":2,"href":"https:\/\/automatethemundane.com\/index.php\/wp-json\/wp\/v2\/posts\/510\/revisions"}],"predecessor-version":[{"id":513,"href":"https:\/\/automatethemundane.com\/index.php\/wp-json\/wp\/v2\/posts\/510\/revisions\/513"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/automatethemundane.com\/index.php\/wp-json\/wp\/v2\/media\/490"}],"wp:attachment":[{"href":"https:\/\/automatethemundane.com\/index.php\/wp-json\/wp\/v2\/media?parent=510"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/automatethemundane.com\/index.php\/wp-json\/wp\/v2\/categories?post=510"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/automatethemundane.com\/index.php\/wp-json\/wp\/v2\/tags?post=510"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}