Skip to main content

Notifications

Announcements

No record found.

Service | Customer Service, Contact Center, Fie...
Suggested answer

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

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!
  • marisolcastro Profile Picture
    marisolcastro 10 on at
    RE: How to hide or show a section based on checkbox for a portal entity form?

    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();

       }

    }

  • Suggested answer
    CRMJetty Profile Picture
    CRMJetty 3,508 on at
    RE: How to hide or show a section based on checkbox for a portal entity form?

    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
    marisolcastro 10 on at
    RE: How to hide or show a section based on checkbox for a portal entity form?

    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
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to hide or show a section based on checkbox for a portal entity form?

    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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans