Hi,
I'm looking for a method to send emails from a template, woith an easy way of adding and editing the templates.
Fist, i tried to use the Jira-scripting-suite to write jython scripts to read from confluenc, but i couln't get it to work.
Do any of you ever had to do something similar? and advices?
Regards,
-Yaron
Community moderators have prevented the ability to post new answers.
You could have a look at the code for https://studio.plugins.atlassian.com/wiki/display/GRV/Built-In+Scripts#Built-InScripts-SendCustomEmail... you could write it in groovy, or continue with python if you prefer.
You can use the confluence remote API to read the templates from confluence, then whatever templating engine you want, to plug the values in.
What you're describing seems perfectly possible... if you have specific issues I'm sure someone will offer more help.
Thanks for the info!
I've started to write it as you said, now i'm kind of stuck on writing the mail template choosing part, I'm trying to do something like this - https://answers.atlassian.com/questions/21273/how-can-i-populate-a-multi-select-custom-field-with-values-from-an-external-source , but to populate a select with page names from confluence. The trubble is that i couldn't find how use JS to connect to the confluence remote API (JSON doesn't support authentications).
I've started writing a web service that will fetch those name for the JS, but i wondered if anyone might think of a better/simpler idea...
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
k, got most of it done, but have one last problem :(
i've writen a python program whitch get the needed pages from confluence, saves them localy, and writing a javascript containing the names of the files created. Then I used the javascript on the description of a text field, to make it a selectable. so far, all is working fine. My trubble is that i'm trying to use the Behaviours Plugin to load the file and show it to the screen (load it to a writable field) so the user could edit it before sending, but it doesn't seem to work..
the groovy source: (in the Behaviours Plugin):
FormField formUserField = getFieldByName("email_preview") FormField formMailOption = getFieldByName("email_template") String tamplate = (String)formMailOption.getValue() tamplate = tamplate.replaceAll(' ','_') def input = new File(tamplate) formUserField.setFormValue(tamplate)
it seems that the '.getValue()' doesn't work on the tweeked field...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You're trying to set the form value to a File object..., you want "new File(...).text". Also please add some debug so you can see what's going on.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not using the file yet, trying to get the string into the field:
FormField formUserField = getFieldByName("email_preview") FormField formMailOption = getFieldByName("email_template") String tamplate = (String)formMailOption.getValue() formUserField.setFormValue(tamplate)
the 'email_template' field is a short text field with the following description:
<script type="text/javascript"> var fieldId = "customfield_10801"; AJS.$(document).ready(function() { console.log("val: " + AJS.$("#" + fieldId).val()); AJS.$("#" + fieldId).parent().append("<select class='select' id='" + fieldId + "' name='" + fieldId + "'></select>"); AJS.$("input#" + fieldId).hide(); var select = AJS.$("select#" + fieldId); select.append("<option>Send solution</option>"); select.append("<option>New case</option>"); AJS.$("input#" + fieldId).remove(); }); </script>
The 'email_template' field is an unlimited text box.
the error logs:
2012-04-30 17:13:23,473 http-8080-1 ERROR yaron 1033x5381x1 mrsja1 192.168.0.105 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/runvalidator.json [onresolve.jira.groovy.BehaviourManagerImpl] Something went wrong with method run in class java.lang.NumberFormatException: For input string: "Send solution" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ... ...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
YEY :) finally got it to work !!! i had to use 'getFormValue()' instead if 'getValue()' and now it works like a charm =D
Many thanks for your help, great plugin!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No problem. You could mark my answer as correct if it was helpful...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If anyone wonders I used a python script to download the content of the email templates from confluence, and saved them localy to the Jira server as well as creating a Javascript file containing all of the confluence page titles. Then i used that Javascript as a description of a text custom field to make it a dropdown menu that contains all of the mail templates (confluence page titles).
Next I used the Behaviours Plugin to display the content of the template that was choosen to the screen and allow the users to edit it. I did that using Groovy validation script.
The last part was another python script as a post script (Jira scripting suit plugin) that send the email to any of the emails that were entered in another custom field.
@Jamie Echlin thanks alot!!! been very helpfull :)
if anyone needs some more info feel free to post here.
Yaron
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No problem. Interesting solution. I would have used groovy for the whole lot but YMMV ;-)
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.