We want to send custom mail to that particular reporter with the attachments on the basis on Department ( Department is nothing but the text CF).
If reporter choose Letters – Address Proof within the Department then it should send the Address Proof file as an attachment.
Since department is a text custom field. Just fetch the value of it
cfValues['Department '] and check if it contains "Letters – Address Proof " using contains() method.
IN the post-function "send custom email" option then you can select - "Include attachments" - "ALL" to send all attachments or if you want to filter out attachment in section
"Custom callback attachement" you can filter the attachements you want to send
like here - https://answers.atlassian.com/questions/18811112.
HI @Tarun Sapra,
I have used the following script code
cfValues['Department']?.values()*.value == ['Letters', 'Address Proof']
and i got the below error
2017-02-06 11:12:41,255 ERROR [utils.ConditionUtils]: ************************************************************************************* 2017-02-06 11:12:41,255 ERROR [utils.ConditionUtils]: Condition failed on issue: null, built-in script:com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail groovy.lang.MissingMethodException: No signature of method: java.lang.String.values() is applicable for argument types: () values:  Possible solutions: valueOf([C), valueOf(boolean), valueOf(char), valueOf(double), valueOf(float), valueOf(int) at Script42.run(Script42.groovy:1) 2017-02-06 11:12:41,269 ERROR [utils.ConditionUtils]: Script follows: cfValues['Department']?.values()*.value == ['Letters', 'Address Proof']
You can try the code first in the "script console", script runner plugin in the admin section has a script console and in that you can try the code. In the admin section of the plugin, search for "script console" and try the code there
As you told earlier i have been tested the below code
def cfValues cfValues['Department'] == 'Letters-Address Proof'
but here i got the below error
Cannot get property 'Department' on null object
cfValues is already available in workflow post-function and not in script console. I meant try to write contains function in the script console like
def value = "Letters Address proof testing" value.contains("Letters") //and now in your post-function you can replace the value with the cfValues['Department'], it's only meant to test out the string contains method.
Hi @Jamie Echlin (Adaptavist),
i am looking for the functionality that whenever the issue will be created by user then the emil should send to that user/reporter with one invoice.docs file.
The file will be same for all user/reporter so for this sending attachment file is i have to store this file some where else or else just need to specify that file name?
Where does the attachment come from? If it's from the current issue you can use a custom closure to define that: https://scriptrunner.adaptavist.com/latest/jira/builtin-scripts.html#_attachments_in_emails
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 ...
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