Hello everyone,
I just get recently started with Microsoft custom Portals and I am trying to hide or display labels and fields based on a checkbox value.
I followed this approach :
https://dynamicsofdynamicscrm.com/2017/08/22/dynamics-365-portal-code-tip-dynamically-showhide-field-based-on-another-field-on-entity-form/
and i think i am almost there, but i am not getting the checkbox value correctly.
This is my code:
$(document).ready(function () {
alert("hello");
$("#venvn_departmenta").change(onReasonChange);
$("#venvn_departmenta").change();
});
function onReasonChange(){
alert("On Reason Change called");
alert("checkbox value a = "+$('#venvn_departmenta').val());
alert("checkbox value b = "+$('#venvn_departmentb').val());
if ($('#venvn_departmenta').val() == true)
{
$('#venvn_qa_areyouamanager_label').show();
$('#venvn_qa_areyouamanager').show();
$('#venvn_qa_activeregionalambulancefacility_label').show();
$('#venvn_qa_activeregionalambulancefacility').show();
}
else
{
alert("checkbox value a = "+$('#venvn_departmenta').val());
alert("checkbox value b = "+$('#venvn_departmentb').val());
$('#venvn_qa_areyouamanager_label').hide();
$('#venvn_qa_areyouamanager').hide();
$('#venvn_qa_activeregionalambulancefacility_label').hide();
$('#venvn_qa_activeregionalambulancefacility').hide();
}
}
At the moment, the script get triggered every time i modify the checkbox venvn_deparmenta, but does not matter if the checkboxes deparmenta and deparmentb are checked or unchecked, I always execute the hidding state and i alert always value = on (checkbox checked value = on, checkbox unchecked value = on too)
does someone know which condition should i analyze to check if the checkbox is checked or not?
Thanks in advance!