I am trying to update the "Security Level" field based on the Team selected by the user.
Here is the code:
def issueKey = event.issue.key
def customFieldName = 'customfield_11048'
def result = get("/rest/api/2/issue/${issueKey}?fields=${customFieldName}")
.header('Content-Type', 'application/json')
.asObject(Map)
Map team = null
import org.apache.log4j.Level
import org.apache.log4j.Logger
def myLog = Logger.getLogger("com.onresolve.jira.groovy")
myLog.setLevel(Level.DEBUG)
if (result.status == 200) {
team = (Map)result.body.fields[customFieldName]
myLog.debug "team ......"+team.value
if(team.value == "Asia"){
def result1 = put("/rest/api/2/issue/${issueKey}")
.header('Content-Type', 'application/json')
.body([
fields: [
security : [
name : "Asia"
],
]
])
.asString()
}
if(team.value == "Africa"){
def result1 = put("/rest/api/2/issue/${issueKey}")
.header('Content-Type', 'application/json')
.body([
fields: [
security : [
name : "Africa"
],
]
])
.asString()
}
if(team.value == "Europe"){
def result1 = put("/rest/api/2/issue/${issueKey}")
.header('Content-Type', 'application/json')
.body([
fields: [
security : [
name : "Europe"
],
]
])
.asString()
}
if(team.value == "Iberoamerica"){
def result1 = put("/rest/api/2/issue/${issueKey}")
.header('Content-Type', 'application/json')
.body([
fields: [
security : [
name : "Iberoamerica"
],
]
])
.asString()
}
if(team.value == "ILS"){
def result1 = put("/rest/api/2/issue/${issueKey}")
.header('Content-Type', 'application/json')
.body([
fields: [
security : [
name : "ILS"
],
]
])
.asString()
}
if(team.value == "North America"){
def result1 = put("/rest/api/2/issue/${issueKey}")
.header('Content-Type', 'application/json')
.body([
fields: [
security : [
name : "North America"
],
]
])
.asString()
}
if(team.value == "Repairs"){
def result1 = put("/rest/api/2/issue/${issueKey}")
.header('Content-Type', 'application/json')
.body([
fields: [
security : [
name : "Repairs"
],
]
])
.asString()
}
if(team.value == "Russia"){
def result1 = put("/rest/api/2/issue/${issueKey}")
.header('Content-Type', 'application/json')
.body([
fields: [
security : [
name : "Russia and Azal"
],
]
])
.asString()
}
if(team.value == "Azal"){
def result1 = put("/rest/api/2/issue/${issueKey}")
.header('Content-Type', 'application/json')
.body([
fields: [
security : [
name : "Russia and Azal"
],
]
])
.asString()
}
myLog.debug "Team : "+team.value
}
Script is working fine but not updating the "Security Level" field.
Log Snippet.
2019-08-23 04:22:51.015 INFO - Serializing object into 'interface java.util.Map' 2019-08-23 04:22:52.036 INFO - GET /rest/api/2/issue/FB-5?fields=customfield_11048 asObject Request Duration: 4241ms 2019-08-23 04:22:52.058 DEBUG - team ......Russia 2019-08-23 04:22:52.630 WARN - PUT request to /rest/api/2/issue/FB-5 returned an error code: status: 400 - Bad Request body: {"errorMessages":[],"errors":{"security":"Security level name 'Russia and Azal' is not valid"}} 2019-08-23 04:22:52.631 INFO - PUT /rest/api/2/issue/FB-5 asString Request Duration: 415ms 2019-08-23 04:22:52.632 DEBUG - Team : Russia 2019-08-23 04:22:52.633 INFO - Run script completed
I have got all the necessary permission.
Kindly help me where I am wrong.
User Executing the Transition was not part of the Security Level.
Hi @Pushpkant Garg ,
I see:
Security level name 'Russia and Azal' is not valid
Error happen only for that name or for any others?
B.R.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Andrew
I got the solution. I was not part of the Security Level. After adding myself to the Security Level, script works fine.
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.