Hi,
I am trying to avoid adding the null value in my email reader. Basically, how I can add validator/condition to skip the field value update if there is no value using groovy script?
Ex:
My email body content is as below
Type:Work Request
Summary: - IN211 - IHCDA - IERA - Visionlink - Question
Severity:
Component:IN211
Division:IHCDA - IERA
ContactName:Brenda Gmail
ContactEmail:brenda.havens@gmail.com
Emailcc:
I see Severity field and EmailCC fields were empty. How I can add the condition to skip adding in issueobject. I tried with
if (Emailcc[1] != null) condition but this giving me error as there is out of
ERROR:
Exception thrown while executing the script. java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
Added condition as below.
How can I skip or add condition to ignore if there is a null/empty
Any help much appreciated.
//SET CC address
String EmailccMatcher = "Emailcc:.*"
String EmailccMatcherspace = "Emailcc:\s"
String EmailccMatch = body.find(EmailccMatcher)
String EmailccValue = null
String[] Emailcc = null
log.debug "CC email matcher" + EmailccMatcherspace
if(EmailccMatcherspace){
log.debug "CC email contain null"
}else if (EmailccMatch) {
//LastNameValue = LastNameMatch.substring(LastNameMatch.indexOf(':'))
Emailcc = EmailccMatch.split(":")
if (Emailcc[1] != null) {
def EmailccField = customFieldManager.getCustomFieldObjectsByName("CC Address Emails").first()
issueObject.setCustomFieldValue(EmailccField, Emailcc[1])
}
}