I have a Policy form based on a Policy entity, I want to show or hide a Quick View within that policy in a section. I got the name for the Quick View as "secCommercialClient" and "secPersonalClient", however I cannot seem to hide/show these quick views. I can do it for the field related to the quick views simply using the following code :
var personalClient = Xrm.Page.getControl("new_personalpolicyholderid");
var commercialClient = Xrm.Page.getControl("new_commercialpolicyholderid");
if(personalClient.getAttribute().getValue() == null)
{
personalClient.setVisible(true/false);
}
else if(commercialClient.getAttribute().getValue == null)
{
commercialClient.setVisisble(true/false);
}
I cannot seem to get the QuickView control to show or hide i get a error saying "Unable to get property 'getAttribute' of undefined or null reference". I double checked in my solution of the form that indeed the name value is secCommercialClient and secPersonalClient, I success at hiding the fields but not the actual Quick Views.
Any ideas?, I am IE's debugger tool to test my scripts on the Policy form of my CRM solution.
I have included the image of the name property of the Quick View, am I using an incorrect name or is there something wrong in my code?
The string you pass in from the control has to be the full id of the field you want to return from within the quick view.
for example setting a quick view on the account form (inserting the form as "MyQuickView") from the "out of the box" quick view for the user entity would allow me to alert the phone field from JavaScript on the account entity like so:
alert(Xrm.Page.getControl("MyQuickView_MyQuickView_systemuser_mobilephone").getAttribute().getValue());
For your example you need to reference the entire Id of the control you want to return from the entity.
I am not allowed to post images on stack exchange yet so I have uploaded them to my drop box for you to see.
https://www.dropbox.com/sh/4agr73jvhe1uxuo/AABU8ce9idnJa0bUaITnXeKAa?dl=0
EDIT: After reading your comment here is how you can hide the quick view by creating a section for it, then hiding the section
Xrm.Page.ui.tabs.get("SAMPLE_TAB").sections.get("SAMPLE_SECTION").setVisible(false);