For a script to run I evaluate a complex condition for
1. a status equals 'Escalated'
2. a single select 'Reviewer needed?' equals 'Yes'
3. a single select 'Service Type' equals 'Email'
4. an Assignee is Empty - (I have not tried this so far, could use help tho)
I tried
cfValues['Reviewer needed?'].value == 'Yes'
cfValues['Reviewer needed?'].getValue() == 'Yes'
cfValues['Reviewer needed?'].getValue().contains('Yes')
with dozens of combinations of single and double quotes
And it fails with
2020-06-13 10:30:30.802 ERROR - The condition: issue.status.name == "Escalated" && cfValues['Reviewer needed?']?.getValue() == "Yes" && cfValues['Service Type']?.getValue().Contains('Email') evaluated to: ["Jira expression failed to parse: line 1, column 66:\n!, -, typeof, (, IDENTIFIER, null, true, false, NUMBER, STRING, new, [ or { expected, . encountered."]
I read thru many posts and documentation including this
PS After moving evaluations to listener script body I got
No such property: cfValues for class: Script1 on line 5
Non-numeric custom fields are not available and need to be got via REST calls
see example for two custom fields we use: Service Type and Reviewer Needed
//getting custom field names
def customFields = get("/rest/api/2/field")
.asObject(List)
.body
.findAll { (it as Map).custom } as List<Map>
def cfServiceTypeId = customFields.find { it.name == 'Service Type' }?.id
def cfReviewerNeededId = customFields.find { it.name == 'Reviewer needed?' }?.id
//getting custom fields values
def result = get("/rest/api/2/issue/${issue.key}?fields")
.header('Content-Type', 'application/json')
.asObject(Map)
if (result.status == 200) {
logger.info("Success getting fields")
serviceType = result.body.fields[cfServiceTypeId]?.value
reviewerNeeded = result.body.fields[cfReviewerNeededId]?.value
} else {
logger.info("Error getting fields")
}
This does not work for service desk Request Type field though!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.