Debug custom rules

Rule designers can now use logs and debug custom JavaScript rules when editing to understand the logic behind rule behavior.

What are the benefits?

Now, in the Rules Editor, you can create and debug a rule at the same time, allowing you to understand a rule's behavior and to identify and correct failures before testing. The new debug functionality is used by calling the logMsg() helper function when running a rule in debug aginst existing subject's data. Adding log statements at different key points of the rule expression allows you to get relevant information on the rule's performance, by displaying values of defined variables and messages that reveal the logic behind rule behavior. Additionally, you get error descriptions whenever an exception occurs.

Details for rule designers

Here's what's new for you when creating or editing rules in Testing mode:
  • While working in the Rule Editor, you can place log statements where needed in the JavaScript expression to reveal how data is being processed at specific points of the code when the rule is running.
  • A new Debug button is introduced in the Rule Editor screen. When clicked, changes to the JavaScript expression are saved and executed against the current subject's existing data.
  • When the debug process starts, a log window appears at the right of the Rule Editor dialog and outputs log information. In the event an exception occurs, the stack trace details and error messages are displayed along with the logs, providing additional information about the rule's failure or unexpected behavior.
  • After reviewing log information, you can change the rule expression and repeat the process for further debugging until the rule works as expected.

All rule saving requirements must be fulfilled prior to clicking Debug, which saves the JavaScript expression. Any compilation error or missing requirement will not allow the debug process to complete.

To make the most out of this new feature,don't forget to review the logMsg() helper function documentation and usage tips.

Already working in a live study?

As soon as this release is available, rule designers can begin to debug any newly created or existing custom rule for all studies in Testing mode. The debug functionality is not available for live studies in Production mode due to security constraints.

More information about this functionality will be featured in Information for CRO and Sponsor Users. See Create and manage custom rules.