web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

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

Hide section based on multiple conditions

(0) ShareShare
ReportReport
Posted on by 27

Hi everyone,

Using Jscript, I want to hide/show a section based on:

  1. Whether a single choice column equals 1
  2. Whether the value in a Dataverse currency column is greater than 20,000,000

I have the first part working:

function ShowHideLabel() {
    var choiceType = Xrm.Page.getAttribute("new_businesscasecategory").getValue(); //replace with the logical name of the choice field 
    if (choiceType != null) {
        if (choiceType == "1") {  // replace with the Value for which you want to display webresource. This would be the associated integer value for the choice field in dataverse
            Xrm.Page.ui.tabs.get("tab_businesscase").sections.get("section_pic").setVisible(true); // replace with TabName and sectionName
        } else {
            Xrm.Page.ui.tabs.get("tab_businesscase").sections.get("section_pic").setVisible(false); // replace with TabName and sectionName
        }
    }
    else {   // For null value webresource will not display           
        Xrm.Page.ui.tabs.get("tab_businesscase").sections.get("section_pic").setVisible(false); // replace with TabName and sectionName
    }
}

But my code is incorrect for the second condition. Could anyone help? Unfortunately my expertise with JScript is lacking.

function Show_UnderToleranceSection() {
    var choiceType = Xrm.Page.getAttribute("new_businesscasecategory").getValue(); //replace with the logical name of the choice field 
    var costvalue = Xrm.Page.getAttribute("cr37a_costcovered").getValue();  
if (choiceType != null || costvalue != null) {
        if (choiceType == "1" && costvalue < 20000000) {  // replace with the Value for which you want to display webresource. This would be the associated integer value for the choice field in dataverse
           Xrm.Page.ui.tabs.get("tab_businesscase").sections.get("section_under_tolerance").setVisible(true); // replace with TabName and sectionName
        } else {
            Xrm.Page.ui.tabs.get("tab_businesscase").sections.get("section_under_tolerance").setVisible(false); // replace with TabName and sectionName
        }
    }
    else {   // For null value webresource will not display           
        Xrm.Page.ui.tabs.get("tab_businesscase").sections.get("section_under_tolerance").setVisible(false); // replace with TabName and sectionName
    }
}

I have the same question (0)
  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    You can use something like the following:

    function Show_UnderToleranceSection() {
        var choiceType = Xrm.Page.getAttribute("new_businesscasecategory").getValue();
        var costvalue = Xrm.Page.getAttribute("cr37a_costcovered").getValue();  
    
        var sectionIsVisible = choiceType == "1" && costvalue > 20000000;
    
        Xrm.Page.ui.tabs.get("tab_businesscase").sections.get("section_under_tolerance").setVisible();
    }

  • Suggested answer
    Ami K Profile Picture
    27 on at


    Thank you very much for the quick response! I have a minor change and updated the last part and this is now working.

    function Show_UnderToleranceSection() {
        var choiceType = Xrm.Page.getAttribute("new_businesscasecategory").getValue();
        var costvalue = Xrm.Page.getAttribute("cr37a_costcovered").getValue();  
    
        var sectionIsVisible = choiceType == "1" && costvalue > 20000000;
    
        Xrm.Page.ui.tabs.get("tab_businesscase").sections.get("section_under_tolerance").setVisible(sectionIsVisible);
    }

     

    For anyone who comes across this post - my original code does actually work, there was a mistake on my end with the section name, but this code is far cleaner.

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    If my reply (or replies) answers your question take a minute and verify the answer. You can do it by clicking "Yes" at the top of the reply (or replies) under the label "Does this answer your question?"

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 82 Super User 2026 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 44 Super User 2026 Season 2

#3
ParthPatel249 Profile Picture

ParthPatel249 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans