You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.
View groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
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.
We often have questions from folks using Jira Service Management about the benefits to using Premium. Check out this video to learn how you can unlock even more value in our Premium plan. &nb...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.