Thursday, August 23, 2012

Crm 2011 JavaScript to set visiblity based on option set value

function SetVisiblity()
{
var option=Xrm.Page.getAttribute("customertypecode").getSelectedOption();
if(option!=null)
{
var x=option.text;
if(x=="Supplier")
{
Xrm.Page.getControl("jmh_supplierstatus").setVisible(true);

Xrm.Page.getControl("jmh_sendpoviaemail").setVisible(true);
Xrm.Page.ui.navigation.items.get("nav_jmh_account_jmh_requisition_Supplier").setVisible(true);
Xrm.Page.ui.navigation.items.get("nav_jmh_account_jmh_purchaseorder_Supplier").setVisible(true);
Xrm.Page.ui.navigation.items.get("nav_jmh_account_jmh_purchaseinvoice_Supplier").setVisible(true);

 Xrm.Page.ui.tabs.get("details").setVisible(false);
 Xrm.Page.ui.tabs.get("administration").setVisible(false);
}
else
{
Xrm.Page.getControl("jmh_supplierstatus").setVisible(false);

Xrm.Page.getControl("jmh_sendpoviaemail").setVisible(false);
Xrm.Page.ui.navigation.items.get("nav_jmh_account_jmh_requisition_Supplier").setVisible(false);
Xrm.Page.ui.navigation.items.get("nav_jmh_account_jmh_purchaseorder_Supplier").setVisible(false);
Xrm.Page.ui.navigation.items.get("nav_jmh_account_jmh_purchaseinvoice_Supplier").setVisible(false);
 Xrm.Page.ui.tabs.get("details").setVisible(true);
 Xrm.Page.ui.tabs.get("administration").setVisible(true);
}
}
else
{
Xrm.Page.getControl("jmh_supplierstatus").setVisible(false);

Xrm.Page.getControl("jmh_sendpoviaemail").setVisible(false);
Xrm.Page.ui.navigation.items.get("nav_jmh_account_jmh_requisition_Supplier").setVisible(false);
Xrm.Page.ui.navigation.items.get("nav_jmh_account_jmh_purchaseorder_Supplier").setVisible(false);
Xrm.Page.ui.navigation.items.get("nav_jmh_account_jmh_purchaseinvoice_Supplier").setVisible(false);

 Xrm.Page.ui.tabs.get("administration").setVisible(true);
 Xrm.Page.ui.tabs.get("details").setVisible(true);
}
}

No comments:

Post a Comment