Hi All,
I am using Scriptrunner -Script Listener code to update a child select list to a value depending on what is selected in parent select list. I get an error stating " This is in Jira Cloud.
PUT request to /rest/api/2/issue/L2-12 returned an error code: status: 400 - Bad Request
body: {"errorMessages":[],"errors":{"customfield_10064":"Specify a valid 'id' or 'name' for Finance Type"Code snippet given below. It is failing in the PUT request. Any help is much appreciated.
def issueKey = issue.key
def financeType='Finance Type'
// 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 customField = get("/rest/api/2/field")
.asObject(List)
.body
.find {
(it as Map).name == 'Feature ArcheType'
} as Map
//assert customField : "Failed to find custom field with given name"
// Extract and store the option from the custom field
def value = (fields[customField.id] as Map)?.value
//assert value : "${value}"
// Return the option value
def finance = null
if(value == "Analysis")
{
finance = "Opex"
}else {
finance="Capex"
}
def result = put("/rest/api/2/issue/${issueKey}")
.header('Content-Type', 'application/json')
.body([ fields:[
customfield_10064: [{value :"CAPEX"}]
//(financeType) : finance
]
])
.asString()