I have the following situation in Dynamics CRM 2016.
I am trying to create a JS web resource that will act on a dropdown field change.
function esitoappuntamento() {
Xrm.Page.getAttribute("new_esito").addOnChange(myOnChange);
function myOnChange() {
if (Xrm.Page.getAttribute("new_esito").getSelectedOption().value == "100000006") {
Xrm.Page.getControl("new_esitoapp").setVisible(false);
Xrm.Page.getAttribute("new_esitoapp").setRequiredLevel("none");
}
else {
Xrm.Page.getControl("new_esitoapp").setVisible(true);
Xrm.Page.getAttribute("new_esitoapp").setRequiredLevel("required");
}
}
}
I have the option set field new_esito
with options/choices. What I want to do is to show the new_esitoapp
field only when the form loads and the new_esito value is 100000006 and someone changes the value from 100000006 to something else from the remaining 7 choices.
Otherwise if when the form loads the new_esito
value is not 100000006, it should not show the new_esitoapp
field independently from what I choose in the new_esito
field from the 8 available choices.
This is working partially as I need it to work, because it is working fine for the case when the form loads and the field value is 100000006.
The problem is that it is still showing the new_esitoapp
field even when the form loads and the value of new_esito
is not 100000006 and I change it to something else.
So the behavior should be:
Form load -> new_esito = 100000006 -> change new_esito -> show new_esitoapp
Form load -> new_esito != 100000006 -> change new_esito -> no show new_esitoapp
Wrong behavior now is:
Form load -> new_esito != 100000006 -> change new_esito -> show new_esitoapp
I hope I made myself clear about what I want to achieve.
Looking forward to your replies.
Regards
==
rather than===
but the Option Set value in Turbo Forms are ints, not strings. – Daryl