I would like to add additional fields (default fields in JIRA e.g Priority, Type) to the email notifications 'reopened issue'. How I can achieve this? Please advise
Community moderators have prevented the ability to post new answers.
Hi Nic,
I added this statement:
#if ($issue.getPriorityObject() && $issue.getPriorityObject().getId() != $constantsManager.getDefaultPriority().getString("id")) $stringUtils.leftPad($i18n.getText("issue.field.priority"), $padSize): ${issue.getPriorityObject().getNameTranslation($i18n)} #end
to this dircetory \templates\email\text\issuereopened.vm, I restarted JIRA and still this field is not visible in the email notifications for me. Do I missed something?
Does your workflow fire the "issue reopened" event, and is that event mapped to the "issue reopened" template? (Those are the defaults, so if you're using the JIRA workflow and haven't changed the config) Also, are you using text or html mail? That change should only affect the text email, so you need to ensure the text is there. Did you restart JIRA after the change? It caches stuff, including email templates sometimes. Finally, although I think your code looks correct at a glance, could you add a bit of debugging - literally drop in some plain text like "My fields should be next" on the line above the "if", so that we can see that we're getting the right email
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.
Ah, you missed the point in my earlier comment. You have been editing the text vm file, and that is an html email. You need to either swap to text emails or go edit the html templates.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, although with html email, you need to be a bit careful with the layout. If you get the text in the wrong place, it may appear in the wrong place, or not at all. (If in doubt, stick it in a <div>...</div> - that usually means it will at least get displayed)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nic, sorry for bothering you so many times, but I added this code below to the email template (html/issuereopenened.vm) and I did restart JIRA, reopened an issue and still I don't get in the email notification the field with priority. (I also tried stick this code in a <div>...</div>) issureopened.vm template view: #disable_html_escaping() asdasdasdasdasdasd #if ($issue.getPriorityObject() && $issue.getPriorityObject().getId() != $constantsManager.getDefaultPriority().getString("id")) $stringUtils.leftPad($i18n.getText("issue.field.priority"), $padSize): ${issue.getPriorityObject().getNameTranslation($i18n)} #end #genericChangelogMailWithComment("jira.email.title.issue.reopened")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No problem. I assume that the asdas stuff is not coming out either? If not, then it implies that your workflow is not firing the event you need, and/or the event is mapped to the wrong email template, and/or your notification scheme does not link the event to the right email.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nic,
I resolved this question, as first we need to use toString(). and then we can make the substring
Thank you for your help
Cheers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah, glad you got there, despite my cack-handed coding! This is why I'm not allowed to be a developer... ;-)
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.
I resolved one of the issue above, if you could just help me with those additional values in this new created custom ('data') field? (they are marked by red circle in above prt screen)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah, yes, in the background, JIRA stores and retrieves both date and date/time fields in the same way - as a date and time. When the field is just a date, it whacks in "midnight" for the time. All the code that presents dates to the users looks at the field type and if it says "just a date" on it, it simply drops the time component. There's a few things you could do for a date field, but it might be easiest to use brute force in your template. Let's say you're using $issue.getCustomFieldValue("customfield_10201") to get that date string out. Try $issue.getCustomFieldValue("customfield_10201").substring(0,9) to yank out the first 10 characters.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nic, forget the above questions. This one will be my last (I promise). Below you will find screen shot from new notification email which I recevied. I added new custom field (end data) which is data format field. Could you please tell me why the data format has some additional values at the end?
Image 1.png
$stringUtils.leftPad($issue.getCustomField("customfield_10201").name, $padSize): $issue.getCustomFieldValue("customfield_10201")
And if you could give me the advise how I can customize this field like the other fields/values? (e.g. Resoultion: Fixed - I mean here font-size, font-family etc)?
Many thanks,
Sebastian
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 Nic,
thank you for your response, it's multi-select option. I added this code :'[1].getValue()' and below is te screen shot from mail notification which I received
Image 1.png
If I may ask about one more additional thing: is there any way to customize value from custom field like the other values? (e.g. Resoultion: Fixed - I mean here font-size, font-family etc)?
Sorry for bothering you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ahh, it's a multi-select. Ok. Try:
$issue.getCustomFieldValue("customfield_10100")[1].getValue()
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.
Ok, what does just $issue.getCustomFieldValue("customfield_10100") do? Something is failing me on this and I can't see it. Oh, and also $issue.getCustomFieldValue("customfield_10100").getClass().toString()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nic,
thank you for the response, but unfortunately it does not work. Below you will find code which I changed:
#if ($issue.getCustomFieldValue("customfield_10100")) $stringUtils.leftPad($issue.getCustomField("customfield_10100").name, $padSize): $issue.getCustomFieldValue("customfield_10100").getName() #end
This is the email confirmation which I get: any thoughts?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Bother. It is be getValue() rather than getName() Sorry about that, I get my field types mixed up a lot!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
"It is be"? The coffee can't have reached my grammar neurons. It is getValue()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nic,
below you will find code which I have in the email\html\issueresolved.vm template:
#disable_html_escaping() #set ($resolution = "<strong>$textutils.htmlEncode(${issue.getResolutionObject().getNameTranslation($i18n)}, false)</strong>") #defaultMailHeaderWithParam("jira.email.title.issue.resolved", $changelogauthor, $resolution) #if ($comment) #parse('templates/email/html/includes/patterns/comment-top.vm') #end #rowWrapperNormal("#parse('templates/email/html/includes/patterns/issue-title.vm')") #if ($issue.getCustomFieldValue("customfield_10100")) $stringUtils.leftPad($issue.getCustomField("customfield_10100").name, $padSize): $issue.getCustomFieldValue("customfield_10100") #end #if ($changelog) #rowWrapperNormal("#parse('templates/email/html/includes/fields/changelog.vm')") #end #set ($commentActionBody="#parse('templates/email/html/includes/patterns/comment-action.vm')") #rowWrapperNormal($commentActionBody) #parse("templates/email/html/includes/footer.vm")
I am trying to display value from custom field, it is displaying the value correctly, but with some strange customization(please see attached file). Is there anything what can I do to display this value from custom field as other? (e.g. Change By)
Image 2.png
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm guessing that "sex" is a custom field with a select list? And you've done something like $issue.getCustomFieldValue(customfield("sex)) in the template? If that's true, it's because Jira has handed the velocity an "option" instead of a string and the [] are just saying "this is my best guess on how to display this". Try adding .getName() to the end - that should get the option represented as the string you've got in the name.
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.
Oops. My apologies... I remember typing an answer for this, but I suspect I wandered off or shut down before clicking "comment". Anyway, the gist of it was that you need to do one of three things. Look at issuesummary.vm - it's a block of code that is used by almost all the emails, so its standardised and changes will appear in all the issues. - if you want your data to appear on all emails, include it in the issuesummary file instead - if you only want your code on re-opened, then you could code it into issuesummary and surround it with #if (test for reopened) (your code) #end - it might be neater and clearer to drop the #parse issuesummary.vm line from re-opened and implement the parts you need from it manually in the reopened template (including your code)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I changed the default workflow so íssue reopened' is avaiable and I am getting an email notification. Also I put this code into the ''issue reopened'' template under the text email. I restart JIRA after change. Below you will find code which is currently in my email\text\''íssue reopened'' template.
#disable_html_escaping() #parse("templates/email/includes/issueplugins.vm") [ ${baseurl}/browse/${issue.getKey()}?page=${tabpanel-all} ] #headerTitleText($i18n.getText("template.issue.reopened.by", $remoteUser.displayName, $issue.key), $remoteUser.displayName) #changes(["resolution"]) #comment() #visibilityText() #if ($issue.getPriorityObject() && $issue.getPriorityObject().getId() != $constantsManager.getDefaultPriority().getString("id")) $stringUtils.leftPad($i18n.getText("issue.field.priority"), $padSize): ${issue.getPriorityObject().getNameTranslation($i18n)} #end #parse("templates/email/text/includes/issuesummary.vm") #parse("templates/email/text/includes/footer.vm")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, and what happens if you add a line of text above your #if block?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.