I am trying to show and hide sections on a form based on a field value (currency field type). This does not appear to be working and all sections always show regardless of field value. I have added this to the form properties for onload and onsave and on the amount requested field for onchange. The default for each section is visible. (I added the alerts to see if it was working but nothing is being shown in the alert either)
// JavaScript source code
//Show/hide approval sections on CER form based on Amount Requested Value
function showHideApprovalSections() {
//get field value
var AmountRequested = Xrm.Page.data.entity.attributes.get("msft_amountrequested").getValue();
{
if (AmountRequested < 1,000,000)
//hide sections based on value
{
Xrm.Page.ui.tabs.get("approvals").section.get("ceo").setVisible(false);
Xrm.Page.ui.tabs.get("approvals").section.get("cfo").setVisible(true);
Xrm.Page.ui.tabs.get("approvals").section.get("coo").setVisible(true);
Xrm.Page.ui.tabs.get("approvals").section.get("bgsrmgr").setVisible(true);
Xrm.Page.ui.tabs.get("approvals").section.get("eng").setVisible(true);
Xrm.Page.ui.tabs.get("approvals").section.get("facilitygm").setVisible(true);
Xrm.Page.ui.tabs.get("approvals").section.get("srfinance").setVisible(true);
// Display an alert box
alert("AmountRequested");
}
else if (AmountRequested < 100,000)
{
Xrm.Page.ui.tabs.get("approvals").section.get("ceo").setVisible(false);
Xrm.Page.ui.tabs.get("approvals").section.get("cfo").setVisible(false);
Xrm.Page.ui.tabs.get("approvals").section.get("coo").setVisible(false);
Xrm.Page.ui.tabs.get("approvals").section.get("bgsrmgr").setVisible(true);
Xrm.Page.ui.tabs.get("approvals").section.get("eng").setVisible(true);
Xrm.Page.ui.tabs.get("approvals").section.get("facilitygm").setVisible(true);
Xrm.Page.ui.tabs.get("approvals").section.get("srfinance").setVisible(true);
alert("Amount < $100K");
}
else if (AmountRequested < 15,000)
{
Xrm.Page.ui.tabs.get("approvals").section.get("ceo").setVisible(false);
Xrm.Page.ui.tabs.get("approvals").section.get("cfo").setVisible(false);
Xrm.Page.ui.tabs.get("approvals").section.get("coo").setVisible(false);
Xrm.Page.ui.tabs.get("approvals").section.get("eng").setVisible(false);
Xrm.Page.ui.tabs.get("approvals").section.get("bgsrmgr").setVisible(false);
Xrm.Page.ui.tabs.get("approvals").section.get("facilitygm").setVisible(true);
Xrm.Page.ui.tabs.get("approvals").section.get("srfinance").setVisible(true);
alert("Amount < $15K");
}
}
}
*This post is locked for comments