Scripts

These scripts can’t guarantee to be executed. Technical users can bypass these scripts by using the Jira REST API directly. Jira REST API allows adding/editing/deleting worklogs and users can use these APIs to bypass all the verifications defined here. This is only valid for scripts, permissions defined in projects settings can’t be bypassed.

Sometimes you may need extra checks for worklogs. Using this feature, you can perform these extra checks on the worklogs at different stages. You can create simple equality checks, which should return “true” for allowing operation to proceed, and should return “false” for failing the operation and displaying the associated error message. If you are migrating from DC/Server versions of WorklogPRO, you may be accustomed to Groovy Scripts, which allow you to perform nearly anything, but Cloud scripts are limited compared to them. But they are simpler to implement.

 

Each check is passed an instance of and object that contains, Jira issue, worklog. Each of these top level object contains lots of details about the Jira issue and worklog. For example worklog object contains worklog attributes.

{ issue: Issue, worklog: Worklog, originalWorklog: Worklog, //only when editing a worklog }

You can see a sample instance of this object here.

Jira Worklog Verification Script

 

How to Write Script Content

You script should evaluate “true” for condition to pass. If it evaluates anything other than “true”, the error message you have defined in “Error message” field will be displayed to the user. “Error message” field can also be parametric, using ${expression} syntax. For example, you can use ${issue.key} to embed “issue key” into the “Error message”.

Below we are providing various Jira worklog verification scripts. For each sample, we are trying to emphasize different things you can do using the Script feature. Note that, these are just examples, you can combine these technics to create your own solutions. If you can’t obtain the result you are looking for, please let us know. We will be more than happy to help you. You can use any Jira issue field, or worklog field to create your condition.

Don’t allow logging work depending on “parent issue” status, if a “parent issue” exist

Type: “Create worklog verification” or “Edit worklog verification“

Content:

$not($exists(issue.fields.parent)) or issue.fields.parent.fields.status.name = "Open"

Error Message:

Parent issue, ${issue.fields.parent.key} should be in "Open" status

Instead of status.name, you can also check status.statusCategory.name for a more generic check.

Only allow logging work in multiples of 15 minutes

Type: “Create worklog verification” or “Edit worklog verification“

Content:

Error Message:

Only allow logging work for a single issue type

Type: “Create worklog verification” or “Edit worklog verification“

Content:

Of course you can check for multiple issue types using field in ["value1", "value 2"] syntax, or use "or" to join multiple expressions.

Error Message:

 

Only allow logging work for issues when they are in a specific status

Type: “Create worklog verification” or “Edit worklog verification“

Content:

You can add/remove any status value inside the array []. If you want, you can use status category instead of status name, issue.fields.status.statusCategory.name = "To Do".

Error Message:

 

Make worklog description mandatory for certain projects

Type: “Create worklog verification” or “Edit worklog verification“

Content:

For “Internal Projects”, require worklog comment mandatory. Of course, you can just use the last expression to make comment required for all Jira worklogs.

Error Message:

Allow logging work only for the current day

Type: “Create worklog verification” or “Edit worklog verification“

Content:

For “Internal Projects”, require worklog comment mandatory. Of course, you can just use the last expression to make comment required for all Jira worklogs.

Error Message:

Make a certain prefix required in worklog descriptions when editing a Jira worklog

Type: “Edit worklog verification“

Content:

Require your users to provide a reason in work description when editing and existing worklog

Error Message:

 

Don't Allow Logging Work If Remaining Estimate is Zero or Not Specified

Type: “Create worklog verification“

Content:

Require your users to provide a reason in work description when editing and existing worklog

Error Message:

Prevent Deletion of certain worklogs

Type: “Delete worklog verification”

Content:

When deleting a Jira worklog, check “Work Type” attribute, and don’t allow deletion of the worklog if it is a “Coding” activity.

Error Message: