Debugging with the debugprint() statement

You can also debug scripts with debugprint() statements in your code that can be enabled when debugging. You can populate your debugprint() statements with useful values for debugging your script. Similar to a breakpoint in a regular IDE, these statements allow you to determine a value at certain point in time in your script. For example, you may have a work detail and require the value after you perform a certain calculation.

Note: This procedure also outlines how to delete debug output logs through the Script Output window or through an archiving task.

To debug an existing script with the debugprint() statement:

  1. Select Maintenance > System Administration > Scriptable Customizations > Extension Script.
  2. Select an existing custom script and click Load.
  3. Insert debugprint() statements at the points in your code where you can test for values. These debugprint() statements only generate debug output if you enable debugging (outlined below). Therefore, you can leave the statements in your code even if you are not debugging. See examples of the debugprint() statement in the code snippet below.
    
        void execute(final RCContext context) throws Exception {
    
    debugprint(“Test 1”) 
    
           RCParameters parameters = context.getParameters()
            String rateType = parameters.getParameter(PARAM_USE_RATE_TYPE)
            String rateMode = parameters.getParameter(PARAM_USE_RATE_MODE , "GREATEST")
            boolean isApplyHtypeToBaseRate =     Boolean.valueOf(parameters.getParameter
    (PARAM_APPLY_HTYPE_MULTIPLE_TO_EMP_BASE_RATE, "true")).booleanValue()
     
    debugprint(“Test 2”)
            if (!rateType.equals(RATE_TYPE_BASE)) {
                if (rateType.equals(RATE_TYPE_PIECE)) {
                    applyRateService.applyPieceRate(context, rateMode, isApplyHtypeToBaseRate)
    
  4. To save your changes, click Save.
  5. Select the Enable debugging check box. This enables the debugprint() statements in your code for 1 hour, after which debugging is disabled.
  6. Next, you can perform an action in WFM that triggers your rules and conditions to fire. An example of this is found in Testing your custom script in WFM.
  7. After your custom rules and conditions are triggered, you can see an output of “Test 1” and “Test 2” (the debugprint() statements in the example above) in Maintenance > System Administration > Scriptable Customizations > Script Output Window.
  8. The Script Output Window displays a table with this information to help you debug your script:
    • Del: Select the check box to consider it for deletion.
    • Timestamp: Timestamp of when the script ran.
    • Extension Script: Name of the custom script.
    • User: User that initiated the request.
    • Application: Application that ran the script. Often this value is “Application Server” or “Job Scheduler”.
    • Thread ID: Thread ID of the script.
    • Request Source: Where the script ran.
    • Line Number: Line number of the output.
    • Debug Output: Output of the debugprint() statement.
  9. Select logs for deletion using the Del check box.
  10. Click the Select All button to select all visible log records.
  11. Click Save to delete the log records.
    Note: You can schedule an archive task that includes the EXTENSION SCRIPT DEBUG LOG PURGE archive policy definition to remove records older than one day. See the Infor Workforce Management Time and Attendance Implementation and Administration Guide for more information on scheduling an archiving task.
  12. Based on your results, you may be required to repeat this process if debugging was unsuccessful.