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 must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You said in your question that it's a text CF and not a list, the script you wrote is for a list of values and not a single text field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
can you help me here to write Text CF script code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
cfValues[
'Department'
]?.contains(<your text>))
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
if i use .contains() method then it gives me error like
can not find matching method
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you cast it to (String) ? First cast it to string and then call the method contains()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
sorry i cant get it can you please write the code here
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Tarun Sapra can u help me out here to get it done.
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.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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.