Advanced Customization > Business Logic Customization > Business Rules > Business Rules Configuration and Execution > Sample Code
  
Sample Code
The following is an example of the workflow conditional syntax in the delivered Change Notice workflow template. The workflow conditional makes a call to the business rules engine for the CHANGEABLE_PRE_RELEASE business rule set. The CHANGEABLE_PRE_RELEASE business rule contains the CHECKOUT_RULE and RELEASE_TARGET business rules.
Routing Expression
result = "NOT_READY";

com.ptc.core.businessRules.engine.BusinessRuleSetBean[] ruleSetBeans =
new com.ptc.core.businessRules.engine.BusinessRuleSetBean[] {
com.ptc.core.businessRules.engine.BusinessRuleSetBean.
newBusinessRuleSetBean("CHANGEABLE_PRE_RELEASE", "wt.change2.ChangeRecord2")
};

//Invoke the business rule engine
com.ptc.core.businessRules.validation.RuleValidationResultSet resultSet =
wt.businessRules.BusinessRulesHelper.engine.execute(primaryBusinessObject,
ruleSetBeans);

if ( !resultSet.hasResultsByStatus(com.ptc.core.businessRules.validation.
RuleValidationStatus.FAILURE)) {
result = "PROCEED";
}
else {
//This line of code will start exception handling for the business
rules that failed
businessRulesResultSetGlobal = wt.businessRules.BusinessRulesHelper.
serialize(resultSet);
preReleaseConflictsMsg = new wt.util.WTMessage("com.ptc.windchill.
enterprise.change2.change2ClientResource", com.ptc.windchill.enterprise.
change2.change2ClientResource.BUSINESS_RULES_PRERELEASE_VALIDATION_MSG,
null).getLocalizedMessage();
preReleaseConflictsMsg = preReleaseConflictsMsg + "\n" + resultSet.
getFailedRulesMessage(java.util.Locale.getDefault());
}
Note that if the validation results are not successful, the attribute businessRulesResultSetGlobal is set to the serialized string of the validation result set. The “View Conflicts” report link will show up on the “Audit Change Notice” and “Resolve Release Conflicts” workflow task pages.