I'm trying to use the "Send a Custom Email" option under Script Listeners with the Scriptrunner add-on.
Particularly, I want to send an email when the following 4 conditions are met:
Right now, I have the email set to fire on an Issue Updated event with the following Condition & Configuration:
(issue.issueType.name == 'Game Bug') && (cfValues['Game Mode'] == 'RB') && (cfValues('Level') == 'whitebox_01' && (issue.getStatusObject.getName() == 'Reviewing')
I believe some of my syntax is off on the condition, particularly referencing the custom field names correctly.
You can use the following condition which should work for your case:
issue.issueType.name == 'Game Bug' &&
issue.status.name == "Reviewing" &&
cfValues['Level']?.value == 'whitebox_01' &&
cfValues['Game Mode']*.value.contains('RB')
Hope this helps.
Thanks for the reply. Can't get the 'Game Mode' condition to execute properly. It returns a log with this error:
2017-12-12 10:06:47,187 ERROR [workflow.ScriptWorkflowFunction]: ************************************************************************************* 2017-12-12 10:06:47,187 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: SP-135891, actionId: 281, file: null groovy.lang.MissingPropertyException: No such property: summary for class: groovy.lang.Binding at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.constructMail(SendCustomEmail.groovy:485) 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:465) at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail$constructMailWithConditionResult$0.callCurrent(Unknown Source) 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:561)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can check checkbox and multi select like this
ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Game Mode").getValue(issue).findAll{it.toString().equals("RB")}.size() > 0
ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Level").getValue(issue).findAll{it.toString().equals("whitebox_01")}.size() > 0
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the response.
Using those conditions by themselves is giving me the following error:
[Static type checking] - The variable [ComponentAccessor] is undeclared.
How do I declare the ComponentAccessor as a variable in a Condition/Configuration?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Add as the first line of your script
import com.atlassian.jira.component.ComponentAccessor
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
With the added import line, I still get this log and no email sent:
2017-12-13 10:21:40,528 ERROR [workflow.ScriptWorkflowFunction]: ************************************************************************************* 2017-12-13 10:21:40,528 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: ST-136280, actionId: 281, file: null groovy.lang.MissingPropertyException: No such property: summary for class: groovy.lang.Binding at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.constructMail(SendCustomEmail.groovy:485) 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:465) at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail$constructMailWithConditionResult$0.callCurrent(Unknown Source) 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:561)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.