Why cfValues['ENT_NOTIF_ESCALADO'] != null condition doesn't returns false when the customfield has no value?

Hi,

 

I've writen a Bultin Script Listener "Send a custom email". In this listener I've included the condition:

 

cfValues['ENT_NOTIF_ESCALADO'] != null

 

The customfield ENT_NOTIF_ESCALADO is the customfield used in the field: "To issue field". The content of this customfield is the list of email addresses to send in the email (i.e: person1@xxx.es, person2@xxx.es, person3@xxx.com). The idea is not to send the email in case of the list was empty.

 

I've tested the listener with an issue on which the customfield ENT_NOTIF_ESCALADO has value and the result is ok, in the preview it is shown to me that the result of the condition is true.

However, when I test the same listener using an issue on which the customfield ENT_NOTIF_ESCALADO has no value, the result is:

 

java.lang.NullPointerException: Cannot invoke method split() on null object
	at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77)
	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
	at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:32)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:54)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
	at com.onresolve.jira.groovy.canned.workflow.postfunctions.SendCustomEmail.getAddressesFromFields(SendCustomEmail.groovy:507)
	at com.onresolve.jira.groovy.canned.workflow.postfunctions.SendCustomEmail$getAddressesFromFields.callCurrent(Unknown Source)
	at com.onresolve.jira.groovy.canned.workflow.postfunctions.SendCustomEmail.getAllToAddresses(SendCustomEmail.groovy:438)
	at com.onresolve.jira.groovy.canned.workflow.postfunctions.SendCustomEmail$getAllToAddresses.callCurrent(Unknown Source)
	at com.onresolve.jira.groovy.canned.workflow.postfunctions.SendCustomEmail.getDescription(SendCustomEmail.groovy:575)
	at com.onresolve.jira.groovy.canned.CannedScript$getDescription.call(Unknown Source)
	at com.onresolve.jira.groovy.CannedScriptListener.getCannedScriptHumanDesc(CannedScriptListener.groovy:121)
	at com.onresolve.jira.groovy.CannedScriptListener$getCannedScriptHumanDesc.callCurrent(Unknown Source)
	at com.onresolve.jira.groovy.CannedScriptRunner.doExecute(CannedScriptRunner.groovy:210)
	at com.onresolve.jira.groovy.CannedScriptListener.super$6$doExecute(CannedScriptListener.groovy)
	at sun.reflect.GeneratedMethodAccessor1188.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1054)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:128)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0(ScriptBytecodeAdapter.java:148)
	at com.onresolve.jira.groovy.CannedScriptListener.doExecute(CannedScriptListener.groovy:33)
	at webwork.action.ActionSupport.execute(ActionSupport.java:165)
	at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:87)
	at webwork.interceptor.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:39)
	at webwork.interceptor.NestedInterceptorChain.proceed(NestedInterceptorChain.java:31)
	at webwork.interceptor.ChainedInterceptor.intercept(ChainedInterceptor.java:16)
	at webwork.interceptor.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:35)
	at webwork.dispatcher.GenericDispatcher.executeAction(GenericDispatcher.java:225)

 

NOTE: I've tried to use also the conditions:

  • cfValues['ENT_NOTIF_ESCALADO'] != null 
  • cfValues['ENT_NOTIF_ESCALADO'] != ""


    The result is always the same.

Any idea?

Thanks in advance

 

Begoña

4 answers

This widget could not be displayed.

Non-standard custom fields are not supported, as there's no standard way of retrieving the value from them and parsing it. 

Ok, thanks Jamie

This widget could not be displayed.

Perhaps it's an empty list.

Just use:

cfValues['ENT_NOTIF_ESCALADO']

and let "groovy truth" do the work.

The result is the same :-(

can you attach a screenshot of the config and include the versions.

This widget could not be displayed.

Versions:

JIRA 6.1.7

Script runner 2.1.16

Here you have the screenshots with the configuration and the result with:

ENT-17297 on which the ENT_NOTIF_ESCALADO has no value

ENT-17298 on which the ENT_NOTIF_ESCALADO has value

thanks. What type of field is ENT_NOTIF_ESCALADO ? Is it called like, all upper case?

This widget could not be displayed.

It is a Database Information customfield as you can see in the screenshot 

It is called ENT_NOTIF_ESCALADO (all upper case)

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

241 views 1 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you