Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Change Field Based on Status

Chris Woodruff
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 11, 2018

Hello,

I'd like to add a behaviour to change the value for Sprint to be empty if two conditions are met: one based on status, and another based on assignee. However, I can't seem to figure out how to reference status as a variable. Here's the code I have so far:

 

import com.atlassian.jira.component.ComponentAccessor

def assignee = getFieldByName("Assignee")
def assigneevalue = assignee.getValue() as String
def sprint = getFieldByName("Sprint")
def status = issue.getStatus().name // This is incorrect
def team = getFieldByName("Team")
def teamvalue = team.getValue() as String


if(teamvalue.contains("XYZ") && assigneevalue.contains("Chris")){
switch (status){
case "In Verification":
sprint.setFormValue("") // This may not be the best way of achieving empty or null - input appreciated!
break
}
}

1 answer

0 votes
Raynard Rhodes
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 11, 2018
Chris Woodruff
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 12, 2018

Thanks, this helped resolve that problem around the issue variable. I now have:

 

import com.atlassian.jira.component.ComponentAccessor

def assignee = getFieldByName("Assignee")
def assigneevalue = assignee.getValue() as String
def sprint = getFieldByName("Sprint")
def status = underlyingIssue.getStatus().getName()
def team = getFieldByName("Team")
def teamvalue = team.getValue() as String


if(teamvalue.contains("XYZ") && assigneevalue.contains("Chris")){
switch (status){
case "In Verification":
sprint.setFormValue("")
break
}
}

 

This is error-free, however it is not working. The value for Sprint is retained. I also tried:

 

sprint.setFormValue(null)

 

which also did not work.

Suggest an answer

Log in or Sign up to answer