I am trying to populate values in a custom numeric field Contract Terms (field ID 10262) based on a selection in a custom single-select drop-down list field Supplier (field ID 10132) on and issue create event. These fields are on a Jira Service Manager screen. I'm using the following script that runs without error, but it does not populate the Contract Terms field.
I need help troubleshooting why the script isn't populating the Contract Terms field.
import groovy.json.JsonOutput
def issue = event.issue // Get the issue object from the event
def issueKey = issue.key // Get the issue key from the issue object
def supplierFieldId = "customfield_10132" // Replace with the correct custom field ID
def contractTermsFieldId = "customfield_10262" // Replace with the correct custom field ID
def supplierFieldValue = event.issue.fields[supplierFieldId]
def contractMap = [
"British Gas (BG)": -35,
"E-ON Next": -20,
"Scottish Power": -30,
]
def newValue = contractMap[supplierFieldValue]
def updateData = [
fields: [(contractTermsFieldId): newValue]
]
def updateJson = JsonOutput.toJson(updateData)
def response = put("/rest/api/3/issue/${issueKey}")
.header('Content-Type', 'application/json')
.body(updateJson)
.asString()