I'm trying to send a mail via a transition's post-function.
The subject and body fields say, you can enter GStringTemplates, but I can't find any decent documentation about that.
How do I simply insert e.g. custom field foo (id 12345) to the subject and/or body?
http://groovy.codehaus.org/api/groovy/text/GStringTemplateEngine.html
It's a pain doing it in the subject. You need something like this:
Issue ID: ${issue.id}, Custom Field Value: <% out << issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObjectByName("My custom field")) %>
Thank you.
I'll try that, but before that I have to configure a test smtp.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can use the "preview" function to see what the subject will look like. This is highly recommended before firing off emails.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Interesting. Where can I see the preview?
I can configure the field "Preview Issue Key" when editing the transition, but I don't see no button "Preview".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried with this as subject:
"Es wurde ein neues Artefakt $issue zum Deployment gemeldet. cfValues['customfield_12714']".
But it doesn't resolve the custom field and results in this subject:
"[TEST] Es wurde ein neues Artefakt LUUS-1126 zum Deployment gemeldet. cfValues['customfield_12714']"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Answer updated...
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 update. But I fear, it's still not working:
<% out << issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObjectByName("customfield_12714")) %>
2013-01-16 08:33:47,003 http-8081-17 ERROR nabil.sayegh@example.com 513x22538x1 1o7xo1j 10.109.54.241,127.0.0.1 /secure/WorkflowUIDispatcher.jspa [onresolve.jira.groovy.GroovyFunctionPlugin] Error executing post-function java.lang.NullPointerException at com.atlassian.jira.issue.IssueImpl.getCustomFieldValue(IssueImpl.java:938) at com.atlassian.jira.issue.Issue$getCustomFieldValue.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) at groovy.tmp.templates.GStringTemplateScript6$_getTemplate_closure1.doCall(GStringTemplateScript6.groovy:2) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:884) at groovy.lang.Closure.call(Closure.java:412) at groovy.lang.Closure$WritableClosure.writeTo(Closure.java:828) at groovy.lang.Closure$WritableClosure.toString(Closure.java:954) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I also tried with :
<% out << issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObjectById(12714)) %>
and
<% out << issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObjectById(12714L)) %>
But am getting these errors:
2013-01-16 08:51:51,617 http-8081-22 ERROR nabil.sayegh@example.com 531x22643x1 j2tplz 10.109.54.241,127.0.0.1 /secure/WorkflowUIDispatcher.jspa [onresolve.jira.groovy.GroovyFunctionPlugin] Error executing post-function groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.managers.DefaultCustomFieldManager.getCustomFieldObjectById() is applicable for argument types: (java.lang.Long) values: [12714] Possible solutions: getCustomFieldObject(java.lang.Long), getCustomFieldObjects(), getCustomFieldObject(java.lang.String), getCustomFieldObjectByName(java.lang.String), getCustomFieldObjects(com.atlassian.jira.issue.Issue), getCustomFieldObjects(com.atlassian.jira.issue.search.SearchContext)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You need the name of the custom field, not the ID. The name is the name that you see when editing an issue in the UI. If you want to use the ID, change getCustomFieldObjectByName to another method.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Works!
Thank you.
BTW: I tried getCustomFieldObjectById() but it didn't work because it expects a java Long. Do you know how to specify that in Groovy? I tried without quotes and with and without L.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Use either `1 as Long` or `1L`, or `new Long(1)`, no quotes in either case.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I use the plugin script runner and use the script post-function. I use the script "Sending a custom email on a transition'. How insert the value of the custom field present in the issue in the template of the mail? How recove the value by id?
Guis
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Isn't this question the same as the one you are asking? Why do you need the custom field ID? If you need it you can get it from the view custom fields page, or from the db.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
can you explain doesn't work. That should work but issue.statusObject.name is probably better.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI jaime,
Currently we are using jira 6.0.5
we need to display the custom field value in the subject of the email whenever the respective field is updated
the field is a version picker
currently we are using the text mode for email notification.i have edited the issueupdated.vm.i have tried the below template
# if the custom field value is empty print the issuekey.issuetype,and summary else print issuekey,updated custom field value and issue summary
if($issue.getCustomFieldValue("customfield_1001") = "")
($issue.key) ($issue.issueTypeObject.name) $issue.summary
#else
($issue.key) $issue.getCustomFieldValue("customfield_1001") ($issue.issueTypeObject.name) $issue.summary
#end
im not getting the value when the custom field is updated.
please help me with valid template
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
that's a velocity template, not related to my plugin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.