Announcements
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(); } }); });
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.
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
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!!
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:
Result:
All options can be showed when the 'No' option is selected:
When i select 'Yes' option, 'Phone' option will be hidden.
André Arnaud de Cal...
294,125
Super User 2025 Season 1
Martin Dráb
232,871
Most Valuable Professional
nmaenpaa
101,158
Moderator