Mark the due date field as required: behaviour plugin

Hi guys,

I have created a behaviour using behaviour plugin.
When I edit issue priority to major, I want to mark the due date field as required.

The following image is my configuration, but it doesn't work.
image2016-12-23 14:26:23.png

This is my validation script

def priorityField = getFieldById("priority")
def dueDateField = getFieldById("duedate")
def priority = priorityField.getValue()
if(priority == "Major")

Do you have any idea? Thanks.

1 answer

1 accepted

I think Priority field will return integer value and try with code something like follows, 

getFieldById("duedate").setRequired(getFieldByName("priority").getValue() as Integer == 1)

Rambanam is right. Getting the priority field will return a string with an integer value in it.

Also, props for using the boolean syntax of setRequired to its full effect. I might have put the contents in a variable, like:

def priorityValue = getFieldByName("priority").getValue() as Integer
getFieldById("duedate").setRequired(priorityValue == 1)

or maybe just

def isMajor = getFieldByName("priority").getValue() == "1"

It's clearly too close to the holidays if I'm quibbling about style. smile

Thank you very much. Yes, the priority field will return a string (it's id value).

The code snippet that worked for me:

import static com.atlassian.jira.issue.IssueFieldConstants.PRIORITY
def isMajor = getFieldById(PRIORITY).getValue() == "1"

Thank you guys.


Suggest an answer

Log in or Join to answer
Community showcase
Alexey Matveev
Published Saturday in Jira

How to run Jira in a docker container

Everything below is tested on Ubuntu 17.10. I prefer to use Jira in a docker container because: 1. I can install Jira with a couple of commands. 2. I can start and stop Jira just by starting and s...

591 views 6 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot