I have to fields on the same Dynamics CRM form. One is Account Name and the other field is Company. They both share the same field id name which is parentcustomerid. I need to show/hide these fields based on the value of an option set of another field. I can get the Account name field to show/hide but the Company field will not show/hide.
function showHideSourceField() {
var type = Xrm.Page.data.entity.attributes.get("new_type").getValue(); var source = Xrm.Page.ui.controls.get("new_source"); var accountname = Xrm.Page.ui.controls.get("parentcustomerid"); var company = Xrm.Page.ui.controls.get("parentcustomerid"); //Type of Contact is Unaffiliated if (type == 100000004) { source.setVisible(true); accountname.setVisible(false); company.setVisible(false);
You have two possibilities:
1) They are two different fields, and you can simply check this in the form editor, for example one is name
the other is parentcustomerid
2) They are the same field added twice to the form, this is possible inside Dynamics CRM, in this case the first field is parentcustomerid
an the second is parentcustomerid1
, and you can still check if it is the same field inside the form editor.