CRM, SSIS & Integrations ...configuring CRM as a non-coder
  • Home
  • Categories
    • Visual Studio
    • KingswaySoft
    • SSIS
    • JavaScript
    • CRM
    • SQL
    • ERP
    • Azure
    • How-to
    • Clubtimiser A/S
    • Office
    • Personal
  • About me
  • Privacy Policy
CRM, SSIS & Integrations
  • Home
  • Categories
    • Visual Studio
    • KingswaySoft
    • SSIS
    • JavaScript
    • CRM
    • SQL
    • ERP
    • Azure
    • How-to
    • Clubtimiser A/S
    • Office
    • Personal
  • About me
  • Privacy Policy
  • Home
  • CRM
  • How-to
  • JavaScript
  • JavaScript basics: Conditionally hide sections and tabs

JavaScript basics: Conditionally hide sections and tabs

January 23, 2019 Leave a Comment Written by Thomas

I recently started looking into javascript, with the purpose of expanding my customization toolbelt for Dynamics CRM, and I wanted to share some of my small customizations here for others to use (primary for myself to use, as I tend to forget quickly).

One of the first things I wanted to get down, was the ability to show/hide sections and tabs on a form. We can already show/hide fields in CRM using a business rule – but it gets a bit tedious if I have to hide more than 4-5 fields. The standard business rule editor…doesnt really have a well designed UI – in my opinion.

First, how to conditionally hide tabs:

function showHideTab()
{
  var type = Xrm.Page.getAttribute("FIELD").getValue();
    switch(type) {
		case 100000000: // If FIELD value is 100000000, then hide the tab
			Xrm.Page.ui.tabs.get("TAB NAME").setVisible(false);
			break;
	
		default:
			// Shows tab
			Xrm.Page.ui.tabs.get("TAB NAME").setVisible(true);
    }
}

I use a switch statement rather than a if/else/then. But thats just personal taste.

For hiding a section – its basically the same code, but you add a small piece of code to each of the get statements:

function showHideSection()
{
    var type = Xrm.Page.getAttribute("FIELD").getValue();
	
    switch(type) {
        case 1: // If FIELD value is 1, then hide the section
			// Hides section
			Xrm.Page.ui.tabs.get("TAB NAME").sections.get("SECTION NAME").setVisible(false);
			break;
			
		default:
			// Shows section
			Xrm.Page.ui.tabs.get("TAB NAME").sections.get("SECTION NAME").setVisible(true);

    }
}

Thats it for now. I will slowly get more java script basics in here, as I learn more.

CRM, How-to, JavaScript
Dynamics365, How To, JavaScript
Dynamics 365 v9.0 with less padding
Fix: Business Proces Flow not updating stepname

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

The author

KingswaySoft MVP & Microsoft certified professional

My name is Thomas and I am a consultant at a company called netcompany A/S in Denmark. My primary focus is working with SSIS and KingswaySoft, where I perform integrations and datatranformations.

Click for more info

Recent Posts

  • Difference between two dates (SQL, SSIS and JavaScript)
  • Easy way to fetch row count for all tables in a SQL database
  • Create Application user in Azure for use in Dynamics 365
  • SSIS Basics: Merge join
  • Open dashboards in a new window

Useful information

  • Installation guide to KingswaySoft
  • Software download list
  • CRM Object Type Codes
  • CRM State & Status codes
  • Script Repository

Archives

  • May 2020 (1)
  • February 2020 (1)
  • January 2020 (2)
  • August 2019 (1)
  • May 2019 (1)
  • February 2019 (2)
  • January 2019 (2)
  • November 2018 (1)
  • September 2018 (1)
  • August 2018 (3)
  • May 2018 (4)
  • December 2017 (2)
  • August 2017 (1)
  • February 2017 (1)
  • November 2016 (4)
  • October 2016 (1)
  • September 2016 (2)
  • August 2016 (5)
  • June 2016 (4)
  • May 2016 (3)

Useful blogs/links

Henrik Jensen, my good friend and colleague, has a blog regarding EVERYTHING Dynamics crm. He's got 50+ certifications, and he is a force to be reckoned with. Link to his blog (danish): crmblog.dk

KingswaySoft have developed an outstanding piece of software for datamanagement to and from CRM, and I can recommend this toolkit for nearly every situation. Link to their website: kingswaysoft.com

Tag Cloud

Azure Bug CRM 2015 CRM 2016 CRM Online Data Dynamics365 ERP Excel How To JavaScript KingswaySoft Log News Office Outlook Personal Solution SQL SSIS Visual Studio

Categories

  • Azure (2)
  • Clubtimiser A/S (1)
  • CRM (30)
  • ERP (2)
  • How-to (14)
  • JavaScript (3)
  • Office (3)
  • Personal (4)
  • SQL (2)
  • Visual Studio (23)
    • SSIS (23)
      • KingswaySoft (14)

Disclaimer

The information given on the website is tested on a mixture of live production environments and test environments, and therefore I cannot guarantee my information will work for you, if you attempt to follow my steps.
If you experience problems, please feel free to contact me.

@June 7th 2016