I expected this code to make the field mandatory for "Issue Type" = QA or when "Task Type" field is "analysis" or Code Review" for rest of issue types.
Its is working for the change in "Task Type" field values, but not working for "Issue Type" = "QA"
What am I doing wrong?
def selectCFValue = getFieldByName("Task Type").getValue()
def targetField = getFieldByName("SVN Path")
def issueType = getFieldByName("issuetype-field").getValue()
if (issueType == "QA")
targetField.setRequired(true)
else
if (selectCFValue == "Analysis" || selectCFValue == "Code Review")
targetField.setRequired(true)
else
targetField.setRequired(false)
Why not use a field configuration for that issue type and make it mandatory there? that is built in and no code is required.
Ok, so you are suggseting making a duplicate field configuration for QA task as its now using a shared configuration with other issue tupes that do not need this field as required?
I guess I can do that
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes. That is the beauty of the field configuration scheme. You can create different field configurations for each issue type if desired and create the field configuration scheme from them. It is th configuration scheme, not an individual configuration that is tied to the project.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Issue type is not a field (so line 3 is wrong) and when you fetch the object, a simple comparison to a string is never going to work.
Try
if ( "QA".equals (issue.getIssueTypeObject.getName()) )
instead
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.