- Create a new Business Rule:
Name: Lab 5.2 RCA Included
Table: Incident [incident]
Active: Selected
Advanced: Selected
When: before
Order: 125
Insert: Selected
Update: Selected
- Within the executeRule() function in the Script field, type try followed by the <tab> key to insert the try Syntax Editor Macro (created in Lab 2.1)
- Select Format Code icon on the Syntax Editor toolbar to properly align the script
- Update the statement in the catch block to use the server-side gs.log() method instead of the client-side g_form.addErrorMessage() method:
(function executeRule(current, previous ){
try{
}
catch(err){
gs.log("A Runtime error occured: " + err);
}
})(current, previous);
- Examine and write the script in the try:
(function executeRule(current, previous ){
try{
if(current.u_rca.nil() && current.u_rca_included){
current.u_rca_included = false;
}
else if(!current.u_rca.nil() && !current.u_rca_included){
current.u_rca_included = true;
}
}
catch(err){
gs.log("A Runtime error occured: " + err);
}
})(current, previous);
- Select Submit