It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Sending custom email on issue creation

Hi,

 

I'm trying to send custom email to reporter on issue creation using script runner.


Whar am i doing wrong?

I get error below:

Time (on server): Tue Mar 14 2017 11:07:05 GMT+0100 (Środkowoeuropejski czas stand.)
The following log information was produced by this execution. Use statements like:log.info("...") to record logging information.
2017-03-14 11:07:04,967 ERROR [workflow.ScriptWorkflowFunction]: *************************************************************************************
2017-03-14 11:07:04,986 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: null, actionId: 1, file: null
java.lang.NullPointerException
	at com.atlassian.jira.issue.managers.DefaultIssueManager.getEntitiesByIssue(DefaultIssueManager.java:395)
	at com.atlassian.jira.issue.managers.DefaultIssueManager.getEntitiesByIssueObject(DefaultIssueManager.java:410)
	at com.atlassian.jira.issue.managers.RequestCachingIssueManager.getEntitiesByIssueObject(RequestCachingIssueManager.java:155)
	at com.atlassian.jira.issue.comments.CommentSearchManager.getComments(CommentSearchManager.java:106)
	at com.atlassian.jira.issue.comments.DefaultCommentManager.getComments(DefaultCommentManager.java:176)
	at com.atlassian.jira.issue.comments.CommentManager$getComments$5.call(Unknown Source)
	at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.mergeEmailTemplate(SendCustomEmail.groovy:979)
	at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.mergeEmailTemplateBody(SendCustomEmail.groovy:952)
	at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail$mergeEmailTemplateBody$2.callCurrent(Unknown Source)
	at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.constructMail(SendCustomEmail.groovy:474)
	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$0.callCurrent(Unknown Source)
	at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.doScript(SendCustomEmail.groovy:551)


Cancel

1 answer

1 accepted

0 votes
Answer accepted
Tarun Sapra Community Leader Mar 14, 2017

Hi Jan,

 

Make sure that your post-function is after the built-in "Creates the issue originally." post function, as it seems that you are executing the script which is using the "issue" variable even before the issue has been created.

Thanks man... that was so obvious... smile 

Now i have diferent issue... i want to insert Assignee in email content - and i get:

 

2017-03-14 13:28:04,306 ERROR [workflow.ScriptWorkflowFunction]: *************************************************************************************
2017-03-14 13:28:04,308 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: PRES-736, actionId: 1, file: null
groovy.lang.MissingPropertyException: No such property: assignee for class: groovy.lang.Binding
	at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.constructMail(SendCustomEmail.groovy:475)
	at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail$constructMail$0.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
Tarun Sapra Community Leader Mar 14, 2017

there is no variable called "assignee" instead you need to do 

Dear  <% out << issue.assigneeUser?.displayName %>,

Suggest an answer

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

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

1,099 views 7 0
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you