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.ObjectNo such property: DebugPrint for class: groovy.lang.Binding
To resolve the issue, the DebugPrint class must be included as one of the imports at the start of the script:
import com.workbrain2.platform.publ.api.DebugPrint
Next, all lines defining the desired debug messages should qualify their use of the debugprint method with its class name like this:
DebugPrint.debugprint("message_content")
See KB3615058 for more information.
Note: These following combinations result in errors when you run the script:
- If the debug messages are coded as simply
debugprint("message")' and theDebugPrintclass 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 theDebugPrintclass is not imported first, this error is displayed:No such property: DebugPrint for class: groovy.lang.Binding - If the
DebugPrintclass is imported and the debug messages are coded as simplydebugprint("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.