Forums

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

Updating assignee via scriptrunner

jypark August 21, 2019

Hi,

I want to use Fast-track transition and change the assignee at the same time.

My script automatically changes the assignee and also changes the status when I select a custom field value.

 

However, when I set the value of the "custom field" to 'None' and select the assignee, the "Assignee field" value changes to 'unassigned'.

if i set the value of the "custom field" to 'None' and select the assignee, "Additional issue actions" does not work.

 

[Condition]

cfValues['Designated Person']?.value != 'None' || issue.assignee != 'Unassigned'

 

[Action] : Assigned (next status)

 

[Additional issue actions]

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption

def issueManager = ComponentAccessor.issueManager
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def userName = ""

// Here you'll replace for your custom cascade field name
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Designated Person")
log.warn("customField: " + customField)

def customFieldValue = issue.getCustomFieldValue(customField)
log.warn("customFieldValue: " + customFieldValue)

switch (customFieldValue){
case "[RND] SF":
userName = "haimai"
break
case "[RND] HanPrism":
userName = "Hoang"
break
case "[RND] HanPHI":
userName = "Sunil"
break
case "[RND] CPS, HanTops, ECOMS, BTMS":
userName = "hjyun"
break
case "[E&S] IPS, V&V":
userName = "jskim"
break
case "[E&S] Solution":
userName = "ejjoo"
break
case "[CS] Nuclear Maintenance Service":
userName = "buggi79"
break
case "Sales":
userName = "st"
break;
case "Financial Management":
userName = "fm"
break
case "General Management":
userName = "gm"
break

}


issue.setAssignee(ComponentAccessor.getUserManager().getUserByName(userName))
// Here the issue will be updated
issueManager.updateIssue(currentUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)

 

1 answer

1 accepted

1 vote
Answer accepted
Mark Markov
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.
August 21, 2019

Hello @jypark 

"None" and "Unassigned" null values in api.

So condition should look like this

cfValues['Designated Person']?.value != null || issue.assignee != null
jypark August 22, 2019

Hi, @Mark Markov 

Thank you for your reply.


I want to check/ask two things. (number 1, 2)


1. When i select a value from a custom field, the assignee is automatically specified and changed to the next status. (this works very well)

2. When I designate a assignee, it changes to the next status.


But number 2 doesn't work.

When i specify the person, it automatically changes to the next status.However, when I checked the results, there was no one in Assignee field that I had specified, and it was changed to Unassigned.

What should I fix?

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Atlassian Community Events