Debugging complex triggers
When a trigger invokes triggers on related records, it is critical that you use
the trigger debugger to ensure expected results. Use rbv_api.print()
API calls to print additional debugging information including field
values and intermediate formula results.
To debug a trigger:
- On the New Trigger or Edit Trigger page, click
Debug Formula under the formula.
A selector window opens.
- Select the record on which to run the trigger.
The debugging window opens and displays three sections: Parsed Formula, Result, and Original Formula. You can navigate to each section by clicking the section name on the toolbar.
When debugging a Automating business decisions with Corticon rules, a fourth section, Debug, is also included. This section displays the Corticon Server URL, the decision service request data, and the decision service response.
The trigger formula debugger cannot execute database transactions. You can use
the variable rbv_debugFormula
to conditionalize code that
requires a database transaction and debug the rest of the formula. This variable exists when user
invokes the formula in the debugger, but does not exist when running the actual trigger in the
application.
Use the following code pattern to detect both cases. In this example, the function
returns without creating a record if the variable rbv_debugFormula
is present and has a value.
function createRBRecord(rbObjectName,recordData,isAttachReq,attachData){ if(this.rbv_debugFormula !== undefined && this.rbv_debugFormula){ rbv_api.println("Skipping create record for "+ rbObjectName); return; } varrecId=rbv_api.createRecord(rbObjectName,recordData); if(isAttachReq===true && recId){ rbv_api.attach(attachData["relName"],attachData["objName1"], '{!id}',attachData["objName2"],recId); } }