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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Suggested Answer

How to hide or show a section based on checkbox for a portal entity form?

(0) ShareShare
ReportReport
Posted on by 10

I am in need of some help........tried several different ways to hide/show a section on an entity form that is displayed in our D365 portal.

Here is the code:

$(document).ready(function () {
SetSectionVisibility();
$("#new_request").change(SetSectionVisibiity);

});

function SetSectionVisibility() {
var currentval = $("new_request").is(":checked");
if (currentval == true) {
$(".section[data-name='incident_info']").closest("fieldset").show();
}
else if (currentval == false) {
$(".section[data-name='incident_info']").closest("fieldset").hide();
}
}
Right now the section is hidden so it is partially working.  However when I check the box (#new_request) the section does not appear.
Any help would be greatly appreciated!
I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    Hi marisolcastro,

    It seems that "new_request" is the logical name of your checkbox field. I have added a checkbox to the basic form and check this element's id.

    The "new_request" is the span tag id, the checkbox id is "new_request_0" and "new_request_1". So you need to monitor these two inputs' change event rather than "new_request".

    Screenshot:

    pastedimage1663928428250v1.png

  • marisolcastro Profile Picture
    10 on at

    Hi Steve!

    So I went ahead and changed it from a checkbox to the radio button under the formatting option of the form.  The source code now shows the field with [tag:new]_incidentreport_0 and [tag:new]_incidentreport_1 as you showed above.  I tried so many different scenarios to get my section (incident_info) to show if I selected Yes but nothing works.  I feel like the 'else' statement is not working properly and I am not sure what else to try.  Any ideas would be greatly appreciated.

    here is the new code:

    $(document).ready(function () {

     $("[tag:new]_incidentreport_0").change(onDisplaySectionChange);

     onDisplaySectionChange();

    });

    function onDisplaySectionChange() {

     var optionOne = $("[tag:new]_incidentreport_0").val();

     var optionTwo = $("[tag:new]_incidentreport_1").val();

     if (optionOne == 0) {

       $(".section[data-name='incident_info']").closest("fieldset").hide();

     }

     else if (optionTwo == 1) {

       $(".section[data-name='incident_info']").closest("fieldset").show();

     }  

    }

  • Suggested answer
    CRMJetty Profile Picture
    3,512 on at

    Hello marisolcastro,

    Pls refer this thread to hide/show a section on an entity form that is displayed in our D365 portal

    https://community.dynamics.com/crm/f/microsoft-dynamics-crm-forum/267415/how-to-hide-show-the-sections-on-portal-entity-forms 

    I hope it helps,

    Thanks.

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Portal.

  • marisolcastro Profile Picture
    10 on at

    Maulik,

    Thanks for the info however this does not resolve the issue I am having.  I have tried multiple ways but my code is not working,  It will hide the section but when I change the value of the drop down or radio button it does not show.

    $(function() {

       $("new_incidentreport").change(onDisplaySectionChange);

       onDisplaySectionChange();

    });

    function onDisplaySectionChange() {

       var selectedValue = $('#new_incidentreport').find("option:selected").text();

       if (selectedValue === "No")

       {

       $(".section[data-name='incident_info']").closest("fieldset").hide();

       }

       else if (selectedValue === "Yes") {

           $(".section[data-name='incident_info']").closest("fieldset").show();

       }

    }

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 49 Super User 2025 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 27 Most Valuable Professional

#3
Soundari Profile Picture

Soundari 15

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans