Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Javascript does NOT work OnChange but works perfectly OnLoad

$
0
0

Hello. My Javascript code works perfectly OnLoad trigger but Only two of the conditions will be successfully satisfied OnChange of a field, leaving out one condition which is to hide a Quick View section and its field. Here is the code:


       function CaseType_OnChange()
  {
      //Get OptionSet CaseType
      var caseType = Xrm.Page.getAttribute("casetypecode");
      if (caseType == null)
      {
          return;
      }
      //Show or Hide Tab and Sections, if CaseType is Claim
      if (caseType.getValue() == 1)
      {
          ShowOrHideTab("tab_1", true);
          ShowOrHideSection("section_1", true);
          ShowOrHideSection("section_2", true);
      }
      else
      {
          ShowOrHideTab("tab_1", false);
          ShowOrHideSection("section_1", false);
          ShowOrHideSection("section_1", false);
      }
  }

  function ShowOrHideTab(tabName, tabVisibility)
  {
      //Get Tab
      var tab = Xrm.Page.ui.tabs.get(tabName);
      //Set Visibility if tab was found
      if (tab != null)
      {
          tab.setVisible(tabVisibility);
      }
  }

  function ShowOrHideSection(sectionName, sectionVisibility)
  {
      //Get Tab
      var section = Xrm.Page.ui.tabs.get("general").sections.get(sectionName);
      //Set Visibility if section was found
      if (section != null)
      {
          section.setVisible(sectionVisibility);
      }
  }

SO, on that ShowOrHideSection("section_1",false), the section of which it is a Quick View form, it is not getting hidden OnChange of the CaseType field.

What could be the problem?

Best Regards

Junior Consultant


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>