Hi,
We are trying to set a custom field User Picker (Single User) using scriptrunner.
We tried email or accounID but still the Reporting Manager field User Picker (Single User) is not updating.
This is what I noticed, when there is a user already set in the Reporting Manager field, the value will be blank when we run the script.
def customfieldID = 'customfield_10202' // Reporting Manager
//def newFieldValue = 'mark@email.com'
def newFieldValue = '123456%3A6f714ab0-e00b-000e-0000-0000c7d000000' //accountid
def issueKey = 'FAC-152'
def result = put("/rest/api/3/issue/${issueKey}")
.header('Content-Type', 'application/json')
.body([
fields: [
customfieldID: [
id: newFieldValue
]
]
//]).asObject(Map)
]).asString()
if (result.status == 204) {
return 'Success'
} else {
return "${result.status}: ${result.body}"
}
Hi @Mark Sayo ,
Your script to update a user pick field is almost 100% correct, just need to change 'id' to 'accountId'.
So, could you try the following and let me know how you get on?
def updateResult = put("/rest/api/3/issue/${issueKey}")
.header('Content-Type', 'application/json')
.body([
fields:[
customfieldID: [
accountId: newFieldValue
]
]
]).asString()
Kind regards,
Bobby
Hi Bobby,
Now I am getting error 400
PUT /rest/api/2/issue/FAC-152 asString Request Duration: 667ms
PUT request to /rest/api/2/issue/FAC-152 returned an error code: status: 400 - Bad Request
body: {"errorMessages":[],"errors":{"customfieldID":"Field 'customfieldID' cannot be set. It is not on the appropriate screen, or unknown."}}
Serializing object into 'interface java.util.Map'
Please use the ScriptRunner user to complete this task not the Initiating User.
See https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-editIssue for more information.
If you are using the ScriptRunner user then check the Field Configuration
Already check Screen, and the Scriptrunner user.
Still error persist.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ahh, apologies @Mark Sayo , I forgot that the value "customfieldID" in the API call needs to be in brackets, so rather than:
customfieldID: [
accountId: newFieldValue
]
It should be:
(customfieldID): [
accountId: newFieldValue
]
Sorry for the confusion! Could you try that and let me know the results?
Kind regards,
Bobby
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.