Skip to content

Instantly share code, notes, and snippets.

@melamriD365
Last active April 13, 2021 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melamriD365/e1c4ff1c985ba0448e314609f02b1553 to your computer and use it in GitHub Desktop.
Save melamriD365/e1c4ff1c985ba0448e314609f02b1553 to your computer and use it in GitHub Desktop.
How to set up complex conditions for business process flow ?
if (typeof (MEA) == "undefined") { MEA = {} };
if (typeof (MEA.Opportunity) == "undefined") { MEA.Opportunity = {} };
if (typeof (MEA.Opportunity.OpportunityForm) == "undefined") { MEA.Opportunity.OpportunityForm = {} };
MEA.Opportunity.OpportunityForm = {
onLoad: function (executionContext) {
var formContext = executionContext.getFormContext();
formContext.getAttribute('budgetamount').addOnChange(this.setNeedApproval);
formContext.getAttribute('mea_riskscode').addOnChange(this.setNeedApproval);
formContext.getControl('mea_isneedapproval').setDisabled(true);
},
setNeedApproval: function (executionContext) {
var formContext = executionContext.getFormContext();
var budgetamount = formContext.getAttribute("budgetamount").getValue();
var risks = formContext.getAttribute("mea_riskscode").getValue();
//(BUDGETAMOUNT >= 100000 OR (50000 <= BUDGETAMOUNT < 100000 AND (RISK = RISK 1 OR RISK = RISK 2))
if ((budgetamount >= 100000) || (budgetamount >= 50000 && budgetamount < 100000 && risks!=null && (risks.includes(278490000) || risks.includes(278490001)))){
formContext.getAttribute('mea_isneedapproval').setValue(true);
formContext.ui.process.reflow(true);
}
else{
formContext.getAttribute('mea_isneedapproval').setValue(false);
formContext.ui.process.reflow(true);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment