script runner: send custom email workflow.ScriptWorkflowFunction java.lang.NullPointerException Edited

Hello,

 

I'm trying to setup a custom notification when a certain transition happens. 

 

in the transition post-function i have added a line (at the top), with the ScriptRunner's built-in function "Send a custom email", but i do not get that email and i see errors in the logs.

 

Here's how i configured it:

 

Condition and Configuration: <empty>

Email template:

Request initiated and sent to manager(s) for approval

$issue.issueType.name $issue.key
Requestor: <% out << issue.reporter?.displayName %> 
Account validity start: <%out <<issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Account validity start")) %>
Account validity end: <%out <<issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Account validity end")) %>

Area: <%out <<issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Area")) %>

Description: ${issue.description}
 
<% if (lastComment)
    out << "Last comment: " << lastComment
%>

Request should be processed by (Due Date): <% out <<issue.due %> 

Subject template:  Issue $issue requires your approval

Email format: Plain text

To addresses: myself (my email address) for testing phase, will be empty when work completed

To issue fields: currently empty, will be set to "managers_approvers Group" when testing complete.

 

JIRA logs the following thing:

2017-05-22 16:25:22,989 ERROR [workflow.ScriptWorkflowFunction]: *************************************************************************************
2017-05-22 16:25:22,990 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: TESTPR-335, actionId: 11, file: null
java.lang.NullPointerException
	at com.atlassian.jira.issue.IssueImpl.getCustomFieldValue(IssueImpl.java:896)
	at com.atlassian.jira.issue.Issue$getCustomFieldValue$3.call(Unknown Source)
	at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.constructMail(SendCustomEmail.groovy:475)
	at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail$constructMail$1.callCurrent(Unknown Source)
	at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.constructMailWithConditionResult(SendCustomEmail.groovy:455)
	at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail$constructMailWithConditionResult.callCurrent(Unknown Source)
	at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.doScript(SendCustomEmail.groovy:551)
Cancel

 

PS: versions used:

-  JIRA Software 7.0.11

- JIRA Service Desk 3.0.11

- Adaptavist ScriptRunner for JIRA 5.0.4

1 answer

Hi Gabrilel,

Is your send custom email post function before the Create Issue post function ? If that is the case then you have to move the Send CUstom Email after the Create Issue one.

We have a development ticket to improve the diagnostics when the order of the post functions is not the right one - SRJIRA-2081

 

Hi Thanos,

 

Sorry for the delay. The "send custom email" is well after the issue creation step, in 2 different transitions, both with the same errors.

 

Basic worflow involves:

- issue creation (dedicated issue type, issue scheme & workflow)

- user reviews his request, then it sends it for approval to the managers group. When this transition happens, a custom email is supposed to be sent (to users belonging to certain JIRA group)

- once one of the managers approve the request, a second email is to be sent upon positive transition (approval) to another group of people defined in JIRA

- only upon the second  line of approval grants the request, it goes in for implementation. From now on, regular issue events notifications apply.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

80 views 0 5
Read article

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