Business Rule not working with gs.getProperty

triciav
Kilo Sage

I created a (2) system properties that have a comma separated list of sysIds

I have (2) Business Rules to check if the current risk statement sysId is in the system properties

If it is in the system property set the value of the Risk Domain field to either Compliance or Operational

My info message does return the sysID and the sysId returned is in the correct systemProperty

However, the current.u_risk_domain value is not getting set.

Any ideas what I am missing?

 

Business Rule(1) On Before Insert/Update
 
var riskStatement = current.statement.sys_id;
    if (riskStatement, 'IN', gs.getProperty('glide.risk.setdomain.compliance')) {
        gs.addErrorMessage("Compliance "+ riskStatement);
        current.u_risk_domain = 'Compliance';
    }
 
Business Rule(2) onBefore insert/Update
    var riskStatement = current.statement.sys_id;
    if (riskStatement, 'IN', gs.getProperty('glide.risk.setdomain.operational')) {
        gs.addErrorMessage("Operational " + riskStatement);
        current.u_risk_domain = 'Operational';
    }
2 REPLIES 2

AshishKM
Kilo Patron
Kilo Patron

Hi @triciav ,

Is the variable statement reference to other table record? If not, then use just current.sys_id.

For checking riskStatement sys_id in the given list, use indexOf() method.

 

The given If condition is not valid.

Use the below code and test, considering that statement variable has sys_id.

 

 

var riskStatement = current.statement.sys_id;
gs.addInfoMessage("Risk Statement "+ riskStatement);
// get compliance sys_id
var compList =gs.getProperty('glide.risk.setdomain.compliance');
// split the sys_id in arrayLisy
var comListArray = compList.split(',');
	if (comListArray.indexOf(riskStatement) >-1) {
        gs.addErrorMessage("Compliance "+ riskStatement);
        current.u_risk_domain = 'Compliance';
    }

 

 

-Thanks,

AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

@triciav , did you get change to review the updated code, let me know if its working for you.


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution