Create a Business Rule
- Create a New Business Rule:
Name: Lab 6.1 Set CAB Date Table: Change Request [change_request] Active: Selected Advanced: Selected When: before Order: 300 Insert: 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 code
- Update the statement in the catch block to use the server-side gs.log() method instead of the client-side g_form.AddErrorMessage() method
- Examine and write the script in the try block:
(function executeRule(current, previous /*null when async*/){ try{ current.cab_date.setDisplayValue(gs.beginningOfNextWeek()); var nextMonday = current.cab_date.dateNumericValue(); var twoDays = 2*24*60*60*1000; //Milliseconds var nextWednesday = nextMonday + twoDays; curren.cab_date.setDateNumericValue(nextWednesday); } catch(err){ gs.log("A Runtime error occured: " + err); } })(current, previous);- Select Submit