Forums

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

Assignee is Always Null

Andrew Zibuda
Contributor
October 30, 2018

I am trying to write a script to update all child assignee's when an Epic or Story assignee is updated. The problem I am running into is I want to update assignee only when it is the same as what the old assignee was, or it is unassigned. However, when it is unassigned and I try to take displayName value of it to compare to old assignee, I get nullPointerException. So I tried to add

 if(issue.fields.assignee == null)

Before accessing displayName, but then none of the issues got through, even those WITH assignees on them. I then tried printing the issue.fields.assignee and it turns out even if there is an assignee and the sub-fields are populated it is still seen as null. Lastly, I tried to encompass it in a try-catch block, but then it throws the exception every time. If I only try to update fields that HAVE an assignee, it works without exceptions or anything. Below is the full code for the section...any advice would be great I have been stuck on this for some time.

 

if(issueSubTasks.size() > 0){

logger.info(issueSubTasks.size()+" subtasks detected, updating fields on subtasks")

for(issueSubTask in issueSubTasks){
//Update each sub-task only if assignee was the same as the old or is empty
if(issueSubTask.fields.assignee.displayName.equals(oldAssignee))
{
result = put('/rest/api/2/issue/'+issueSubTask.key)
.header('Content-Type', 'application/json')
.body([
fields:[
assignee: issue.fields.assignee
]
])
.asString()
logger.info("subtask updated: "+issueSubTask.key)
}
}
}  

Again, as long as there are no "unassigned' issues going in to this, it works fine. This was the base code before running in to the issue with unassigned, where I tried all the above changes, with no success. 

1 answer

0 votes
Marc Minten (EVS)
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.
October 31, 2018

Did you try ... issue.assignee .... ? (without the ".fields." ?)

Andrew Zibuda
Contributor
November 1, 2018

issue.assignee does not exist

Like Test User likes this

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, jira product discovery, jpd premium, product management, idea management, product discovery, jira premium, product planning, atlassian community, product development, roadmap planning, product prioritization, feature management

Introducing Jira Product Discovery Premium ✨

Jira Product Discovery Premium is now available! Get more visibility, control, and support to build products at scale.

Learn more
AUG Leaders

Atlassian Community Events