Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,741
Community Members
 
Community Events
184
Community Groups

add user to user list if value in fieled is correctly

Help with the script, I need to add the user to the field when creating the task, if two values are selected in the field, field I use Selection List (Drop Down)

i'm using script runner

and i have script:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.user.ApplicationUser

ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def cf = ComponentAccessor.customFieldManager.getCustomFieldObject(10032L); //Соисполнители
def arrayOfComponents = issue.getComponents();
def userList = getCustomFieldValue(issue,10032L)?:[];

for(def comp in arrayOfComponents){
if(comp.getName()=="Email (Почта)"){
userList += [getUser("r.sheraliev")];
}
if(comp.getName()=="FTP (Uzmobile)"){
userList += [getUser("a.malikov")];
}
if(comp.getName()=="AD (Домен)"){
userList += [getUser("o.gulomkodirov")];
}
if(comp.getName()=="JIRA (Confluence)"){
userList += [getUser("m.zaxidov")];
}
if(comp.getName()=="Local Administartor"){
userList += [getUser("o.shodmonov")];
}
if(comp.getName()=="Oasis"){
userList += [getUser("a.malikov")];
}
}

issue.setCustomFieldValue(cf, userList.collect{it})
ComponentAccessor.getIssueManager().updateIssue(currentUser, issue, EventDispatchOption.ISSUE_UPDATED, false)


ApplicationUser getUser(String userName){
return ComponentAccessor.getUserManager().getUserByName(userName)
}
def getCustomFieldValue(issue, Long fieldId) {
issue.getCustomFieldValue(ComponentAccessor.customFieldManager.getCustomFieldObject(fieldId))
}

 

this script add users to user rist if components use

If i select from field Responsible Services "Branch (Infosystems)" and in the second fieled "AD (Домен)" script must add users to users fieled list

QIP Shot - Screen 006.png QIP Shot - Screen 007.png

0 comments

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events