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") { dueDateField.setRequired(true) }
Do you have any idea? Thanks.
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" getFieldById("duedate").setRequired(isMajor)
It's clearly too close to the holidays if I'm quibbling about style.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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" getFieldById("duedate").setRequired(isMajor)
Thank you guys.
Ada.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.