You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
Hello! Hope everyone is safe and health!
I'm looking for a way to insert users from a group field to a multiple user field.
I'm trying to solve this with Scriptrunner Cloud, but I can't insert the accountID user's on the the field.
Thanks for the help!
@Ricardo Cardoso D_ Oliveira it should be something like this:
def issueKey = 'DEMO-9'
// Fetch the issue object from the key
def issue = get("/rest/api/2/issue/${issueKey}")
.header('Content-Type', 'application/json')
.asObject(Map)
.body
// Get all the fields from the issue as a Map
def fields = issue.fields as Map
// Get the Custom field to get the option value from
def customFields = get("/rest/api/2/field")
.asObject(List)
.body as Map
def someGroupCfId = customFields.find { it.name == 'Some Group' }?.id
logger.error(someGroupCfId)
def someUsersCfId = customFields.find { it.name == 'Some Users' }?.id
logger.error(someUsersCfId)
def someGroupCfValueGroupName = (fields[someGroupCfId] as Map)?.name
logger.error("Selected Group:" + someGroupCfValueGroupName)
// Extract and store the option from the custom field
def someUsersfValuesUsers = (fields[someUsersCfId] as Map)?.toString()
logger.error("Selected users:" + someUsersfValuesUsers)
def members = get("/rest/api/3/group/member?groupname=${someGroupCfValueGroupName}")
.header('Content-Type', 'application/json')
.asObject(Map)
.body as Map
def membersAccounts = members.values.collect{it.accountId}
def membersAccountsParam = []
membersAccounts.forEach {
membersAccountsParam.add([accountId: it])
}
logger.error("asdasdasd:"+membersAccountsParam)
logger.error("members:"+membersAccounts.toString())
def result = put('/rest/api/2/issue/' + issueKey)
.header('Content-Type', 'application/json')
.body([
fields:[
// The custom field representing my user picker field
customfield_10041: membersAccountsParam
]
])
.asString()
Let me know if it's working.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Martin Bayer _MoroSystems_ s_r_o__ may you please help me change this script to use in jira automation. My requirement is to copy users from a group from a custom field named Watchers group to a multi user field named watchers list. I am using Jira Cloud
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.