Hey guys,
I have a script that is supposed to make a SOAP call to a different application when a ticket is updated and contains a certain value. Here is basically my script:
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
String username = "username"
String password = "password"
//ID's for custom field and value
String customFieldId = "customfield_11300"
String customFieldValue = "[value1]"
CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager();
CustomField customField = customFieldManager.getCustomFieldObject(customFieldId);
String fieldValue = issue.getCustomFieldValue(customField);
def soapRequest = """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:DskTkt_CreateTicket">
<soapenv:Header>
<urn:AuthenticationInfo>
<urn:userName>${username}</urn:userName>
<urn:password>${password}</urn:password>
</urn:AuthenticationInfo>
</soapenv:Header>
<soapenv:Body>
<urn:create>
<urn:Area>Services</urn:Area>
<urn:CaseType>Service Request</urn:CaseType>
<urn:Description>test</urn:Description>
<urn:GroupID>2000</urn:GroupID>
<urn:GroupIDTxt>2000</urn:GroupIDTxt>
</urn:create>
</soapenv:Body>
</soapenv:Envelope>"""
if(fieldValue == customFieldValue) {
try {
def soapUrl = new URL("soapdomain/services/?webService=CreateTicket")
def connection = soapUrl.openConnection()
connection.setRequestMethod("POST")
connection.setRequestProperty("Content-Type" ,"text/html")
connection.setRequestProperty("SOAPAction", "")
connection.doOutput = true
Writer writer = new OutputStreamWriter(connection.outputStream)
writer.write(soapRequest)
writer.flush()
writer.close()
connection.connect()
def soapResponse = connection.content.text
def Envelope = new XmlSlurper().parseText(soapResponse)
} catch (Exception e) {}
}
If I post this into the script console it works great. I can go into the other application and see that it worked. I then went to setup the listener with 'Issue Update' and it doesn't work. I've modified the JIRA ticket several times selecting that custom field value with no luck. Am I missing something? Thanks for any help!