I'm using the code below in a ScriptRunner custom listener. Bolded in the if statement is a confirmation that the Priority is set to Critical. That all works so far. If I wanted to replace the Priority check with a custom field instead (i.e., check if custom field 'Name' is equal to 'Ryan'), how would the code change? I can't seem to get it to work.
import groovy.json.JsonBuilder
import groovyx.net.http.ContentType
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.Method
def change = event?.getChangeLog()?.getRelated("ChildChangeItem").find {it.field == "priority"}
if (change && issue.priority.name == "Critical") {
// code to ping HipChat room
}