Adding debug print messages to Groovy extension scripts

When adding debug messages to Groovy extension scripts in WFM, errors can occur instead of the expected debug output if the DebugPrint messages are not coded correctly. Common error messages include:
  • Scripts not permitted to use method groovy.lang.GroovyObject invokeMethod java.lang.String java.lang.Object
  • No such property: DebugPrint for class: groovy.lang.Binding
To avoid these errors, ensure sure that:
  • The DebugPrint class is imported at the start of the script.
  • All debug messages qualify the debugprint method with the class name.
  • Debugging is enabled for the script by selecting the Enable Debugging checkbox on the script editing page. Debugging stays active for one hour and automatically turns off after that. DebugPrint statements only work while debugging is turned on.

See KB3615058 for more information.

  1. To add debug print messages to an extension script, login to WFM as a system administrator.
  2. Click Maintenance > System Administration > Scriptable Extensions.
  3. Open the extension script that you want to add debug messages to.
  4. At the start of the script, add the import statement:
    import com.workbrain2.platform.publ.api.DebugPrint
  5. Wherever you want to log debug output, add statements like:
    DebugPrint.debugprint("Test message")
  6. Select the Enable Debugging check box for the script.
    After one hour, debugging automatically turns off and DebugPrint statements stop logging output until you enable debugging again.
  7. Save and test the script.
Note: These following combinations result in errors when you run the script:
  • If the debug messages are coded as simply debugprint("message")' and the DebugPrint class is not imported first, this error is displayed:
    Scripts not permitted to use method groovy.lang.GroovyObject invokeMethod java.lang.String java.lang.Object (script17490753495371967955061 debugprint line 1 message)
  • If the debug messages are coded as DebugPrint.debugprint("message") and the DebugPrint class is not imported first, this error is displayed:
    No such property: DebugPrint for class: groovy.lang.Binding
  • If the DebugPrint class is imported and the debug messages are coded as simply debugprint("message"), this error is displayed:
    Scripts not permitted to use method groovy.lang.GroovyObject invokeMethod java.lang.String java.lang.Object (script1749075549508278284712 debugprint line 3 message)

This behavior applies to any Groovy extension script type that uses DebugPrint for logging.