We can't implement every customer requirements in WorklogPRO, we don't have necessary resources, but also our customers has conflicting requirements. For this reason we have decided to allow our customers to customize WorklogPRO behaviors with Groovy scripts. You can execute various scripts when logging work, approving timesheets. These scripts can be run before an action is performed like logging work, after an action. When scripts are run before an action, you can cancel the action by returning a non-null result from worklog script.
When writing your scripts please refer to our Java API to see available methods and data structures.
Consider the case when logging work or deleting work. Worklog verification highly depends on customers' requirements. To allow each customer to build his own verification logic we have decided to create a scripting interface for worklog verification. You can now write your own Groovy script to verify worklog entry, update, move or delete operation. "Create/Update" script is executed every time when some tries to log work on WorklogPRO's 'Log Work Dialog' or 'Log Work Custom Field'. "Delete" script is executed every time when someone tries to delete a worklog. When moving worklog from an issue to another first "Delete" script is executed and after that "Create/Update" script is executed.
"Pre-Worklog Entry" is not a verification script, it is provides opportunity to modify worklog dialog content or worklog custom field content before it is displayed to user. Using this script you can hide some attributes depending on custom conditions or show preset values to user. This script is passed "worklogPreEntryParameters" which is an instance of "com.deniz.jira.worklog.scripting.WorklogPreEntryParameters" and your script should also return an instance of this object.
Configuring worklog scripts requires Jira Administrator, Jira System Administrator. Due to security constraints WorklogPRO Administrators can't update script. Since you can write arbitrary code and use all Jira services inside the script a script can do anything to your Jira instance although it is executed with privilege of logged in user (the user creating/updating/deleting worklog).
Debugging Your Scripts
You can use println statements to log values to Jira process's standard output for debugging purposes, not atlassian-jira.log file. You can use SLF4J logging to log to atlassian-jira.log file if you want. If you want to use logging please set debug level for the package "com.deniz.jira.worklog.scripting" and use following code to add debug messages to your script.
//please enable logging for package "com.deniz.jira.worklog.scripting" from Administration/System/Logging and Profiling
Logger log = LoggerFactory.getLogger(com.deniz.jira.worklog.scripting.ScriptingService.class);
log.debug("This is debug message");