I'm using the scriptrunner post function create sub task template.
The subtask is being created as expected but i'm trying to update a custom field when the task is created. When i use some code that i found on the Adaptavist website i get an error
https://library.adaptavist.com/entity/update-the-value-of-custom-fields-through-the-script-console
this is the code in the script context window
def response = put("/rest/api/2/issue/${issue.key}")
.header("Content-Type","application/json")
.body([
fields:[
customfield10076: 'Change Exception Approver'
]
])
.asString()
Error
2020-01-07 14:58:13.679 WARN - PUT request to /rest/api/2/issue/RFC-7031 returned an error code: status: 400 - Bad Request body: {"errorMessages":[],"errors":{"customfield10076":"Field 'customfield10076' cannot be set. It is not on the appropriate screen, or unknown."}} 2020-01-07 14:58:13.925 INFO - PUT /rest/api/2/issue/RFC-7031 asString Request Duration: 3200ms 2020-01-07 14:58:15.548 INFO - Serializing object into 'interface java.util.Map' 2020-01-07 14:58:15.549 INFO - POST /rest/api/2/issue asObject Request Duration: 1590ms 2020-01-07 14:58:15.559 INFO - Created subtask completed
customfieldid10076 is the custom field that i'm trying to update. I've confirmed that it is on the screen for the sub-task. The custom field is a single group picker.
If i use the same code and try to update the description it works fine so the issue is definitely to do with the customfield.
Any help appreciated
You seem to have the wrong syntax for identifying the field. The format is 'customfield_nnnnn' not 'customfieldnnnnn'.
Hi, I've updated the script but still get the same error
2020-01-09 08:56:32.714 WARN - PUT request to /rest/api/2/issue/RFC-7123 returned an error code: status: 400 - Bad Request body: {"errorMessages":[],"errors":{"customfield_10076":"Field 'customfield_10076' cannot be set. It is not on the appropriate screen, or unknown."}} 2020-01-09 08:56:32.734 INFO - PUT /rest/api/2/issue/RFC-7123 asString Request Duration: 599ms 2020-01-09 08:56:33.556 INFO - Serializing object into 'interface java.util.Map' 2020-01-09 08:56:33.558 INFO - POST /rest/api/2/issue asObject Request Duration: 783ms 2020-01-09 08:56:33.559 INFO - Created subtask completed
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.