Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Help with scriptrunner code

Hi im trying to assign an issue based on a radio button selected but my code is not working. Radio has two options and based on the option selected a different user should be assigned to the issue when the transition happens. Here is what i have done so far in a script editor. Thanks for any help.

IssueManager im = ComponentAccessor.getIssueManager()
MutableIssue issue = im.getIssueObject("SD-....")

ApplicationUser assignee
UserManager umgr = ComponentAccessor.getUserManager()

final customFieldName = "radioCF"
def customFieldManager = ComponentAccessor.customFieldManager
def dot_cf = customFieldManager.getCustomFieldObjects(issue).find { it.name == customFieldName }

def dot_value = dot_cf.getValue(issue)

if (dot_value == "option1")
{
assignee = umgr.getUserByName('user1')
issue.setAssignee(assignee)

} else if (dotyczy_value == "option2") {
assignee = umgr.getUserByName('user2')
issue.setAssignee(assignee)
}

1 answer

1 accepted

3 votes
Answer accepted

Hi @Adam G  Try below script , add this in Post function . I have tested on my side. It's working.

import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField

final String userName1 = "user1"
final String userName2 = "user2"

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customfield = customFieldManager.getCustomFieldObject("customfield_27460")

if (issue.getCustomFieldValue(customfield).toString() == "Low") {
def user = ComponentAccessor.userManager.getUserByName(userName1)
issue.setAssignee(user)
}
else if (issue.getCustomFieldValue(customfield).toString() == "Medium"){
def user = ComponentAccessor.userManager.getUserByName(userName2)
issue.setAssignee(user)

}

Kindly change Low and Medium value as per your radio button field values. 

Like Adam G likes this

Thank you so much. Works like a charm :). I can move forward because it's not the end of it. Its only the first step of the workflow. Now i need to transition to different status based on the second radio option.  

Like Vikrant Yadav likes this

@Adam G  Great :) Glad to hear it works for you. 

For transition, you no need to write script .Use Fast track transition an issue based on Condition. Hope it works for you. 

 

Thanks!

Like Jakob likes this

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you