I am trying to set a multi-user field using the API - I am running this from the ScriptRunner console, but I don't think this is a ScriptRunner issue.
My code is as follows:
put("/rest/api/3/issue/AB-123")
.header("Content-Type", "application/json")
.body([
fields:[
customfield_11018 : [{id:"<my user id>"}],
assignee: [id: "<my user id>"]
]
])
.asString()
customfield_11018 is a multi-user field, and assignee is a single user field.
When I run this script, there are no errors produced. The assignee is correctly updated, but the multi-user field is set to blank.
Am I doing something wrong, or is this a bug?
Thank you. So the answer is:
put("/rest/api/3/issue/AB-123")
.header("Content-Type", "application/json")
.body([
fields:[
customfield_11018 : [[id:"<my user id>"]],
assignee: [id: "<my user id>"]
]
])
.asString()
Hi Nick,
Thank you for your question.
I can confirm that we have an example snippet located here which shows how to set different type of user picker fields with ScriptRunner for Jira Cloud.
Inside this snippet, we show how to set a multi-user picker custom field which requires you to pass an array for each user to be set as a comma-separated list and you can use this example as a reference guide to help you create the script which you require.
I hope this information helps.
Regards,
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you able to explain why the documentation says to use curly brackets?:
"customfield_11458" : [ { "name":"inigomontoya" }, { "name":"tommytomtomahawk" }]
See: https://developer.atlassian.com/cloud/jira/service-desk/rest/#fieldformats
Is this difference to do with ScriptRunner?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nick,
Thank you for confirming that the example which we have provided you have resolved your issue and has allowed you to resolve your issues
I notice that page is from the Jira Service Desk rest API's and is only relevant to Jira Service desk and is not valid for Jira Core or Jira Server projects which are example is based on.
I would advise contacting Atlassian to check if that example in that documentation link is still valid.
Regards,
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think that the documentation is correct. It is because the script is written in Groovy, which substitutes {} for []. In Groovy, {} is reserved for Closures.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nick,
Thank you for confirming this and for confirming that your issue has been resolved.
Regards,
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is there any way to use name?!
customfield_10003 : [["name":"firstname secondname"]] or customfield_10003 : [[name:"firstname secondname"]] - did not work
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Andrey,
I can confirm that you cannot use a user's name inside of Jira Cloud as Atlassian only allows you to specify users via their accountId since the GDPR changes they made and they enforce this in the rest API's which means you cannot specify users via their username.
Regards,
Kristian
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.