Create a Business Rule

  1. Create a New Business Rule:
  2. Name: Lab 6.1 Set CAB Date
    Table: Change Request [change_request]
    Active: Selected
    Advanced: Selected
    When: before
    Order: 300
    Insert: Selected
    
  3. 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)
  4. Select Format Code icon on the Syntax Editor toolbar to properly align the code
  5. Update the statement in the catch block to use the server-side gs.log() method instead of the client-side g_form.AddErrorMessage() method
  6. Examine and write the script in the try block:
  7. (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);
    
  8. Select Submit

results matching ""

    No results matching ""