Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Hiding/Removing the global option set value in D365 Portal web form(Showing as multi select field on portal form)

Posted on by 77

Hi,

I want to hide one of the multi-select option value in portal form using JavaScript(In CRM, it is a global option set which is used on entity, I have created an option set field on entity and using an existing global option set) which will display on the portal form when radio button is true.

I have tried the following code on both the options but it didn't work, could you please let me know how we can achieve it. Thanks

$("#new_optionset").children('option:eq(938700002)').hide();

or

$(document).ready(function(){
	$("#new_twooptions").change(function () {
        // Get value of your trigger field
        let currentVal = $("#new_twooptions option:selected").val();

        //do some validation
        if(currentVal == "1") {
            $("#new_optionset option[value='938700002']").hide();
        } else {
            $("#new_optionset option[value='938700002']").show();
        }
    });
 });

  • D365Admin Profile Picture
    D365Admin 77 on at
    RE: Hiding/Removing the global option set value in D365 Portal web form(Showing as multi select field on portal form)

    Hi Leah Ju,

    I worked it out on my own where I was doing something wrong in the script so it didn't work before but now it is working as expected and your code is also correct. Thanks for your help on this.

  • D365Admin Profile Picture
    D365Admin 77 on at
    RE: Hiding/Removing the global option set value in D365 Portal web form(Showing as multi select field on portal form)

    Hi Leah Ju,

    I tried once again by creating the option set and the above code works but it is not working on Multi select which is a option set in CRM. Do you have any idea why the multi select not working? Please suggest if you have any ideas? Thanks

  • D365Admin Profile Picture
    D365Admin 77 on at
    RE: Hiding/Removing the global option set value in D365 Portal web form(Showing as multi select field on portal form)

    Hi Leah Ju,

    Thank you very much for your time in answering my query.

    I confirm this code will work when we show the option set field as option set on CRM Portal but we are showing the option set field as multi select field on the portal and storing the selected values on hidden text field so that is why probably your given code didn't work either.

    Also, I tried using the below code to remove or hide the value from the multi select but it is also having the same behavior. I can able to hide/remove on the option set value but we are showing the option field as multi select(Before Microsoft was not supported Multi select, now we can create multi select for Portals also) and that value is still showing on the multi select field.

    $("#new_test option[value='123400000']").hide();
    
    $("#new_test option[value='123400000']").remove();

    It might be possibly, I might have missed something which I will re-verify!!

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Hiding/Removing the global option set value in D365 Portal web form(Showing as multi select field on portal form)

    Hi Partner,

    It seems that the '$("#new_twooptions option:selected").val()' is not working in portal, you can try to use the following code:

    $(document).ready(function(){
    	$("#custom_twooptions").change(function () {
            // Check two options field 'Yes' option is checked or not
            var currentVal =  $('#custom_twooptions_1').is(":checked");
    
            //do some validation
           if(currentVal == true) {
                $("#custom_optionset option[value='1']").hide();
            } else {
               $("#custom_optionset option[value='1']").show();
           }
        });
     });

    Note: 

    Two fields:

    pastedimage1647329575432v1.png

    pastedimage1647334395729v4.png

    Result:

    All options can be showed when the 'No' option is selected:

    pastedimage1647329740391v2.png

    When i select 'Yes' option, 'Phone' option will be hidden.

    pastedimage1647329764145v3.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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans