Ok, so....I've got a scriptrunner post function email set up to let our Testing team know that the build is ready for testing and that there are defects included that need testing.
I've got no problem pulling the custom field "Fixes Defect/s" (highlighted in screen shot and created as a scripted Issue Picker field) but would like to list them and provide a hyper link as I have with the baseline issues (ie RMT-501 & RMT-499)...see below.
Is this possible?
What I'd actually like it to pull is exactly how it shows up on the ticket itself:
And see this rich text format transfer from ticket to email
Instead of looking like this:
Thanks
Condition and configuration:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.RendererManager
import com.atlassian.jira.issue.fields.renderer.IssueRenderContext
import com.atlassian.jira.issue.fields.renderer.JiraRendererPlugin
def rendererManager = ComponentAccessor.getComponent(RendererManager)
def issue = ComponentAccessor.issueManager.getIssueByCurrentKey(issue.key)
def wikiRenderer = rendererManager.getRendererForType("atlassian-wiki-renderer")
def renderContext = new IssueRenderContext(issue)
config.deschHTML = wikiRenderer.render(issue.description, renderContext)
return true
Script used for email:
<p>Dear QA Testers,</p>
<p>${issue.summary} (<strong><a href="${baseUrl}/browse/${issue.getKey()}">${issue.getKey()}<a/></strong>) for ${issue.getParentObject().getSummary()} has been completed and is ready for QA Testing. </p>
<p>Items that require Quality (QA) testing are listed in the table below.</p>
<p><br>${deschHTML}</p></br>
<p>If this Build Deployment contained fixes for any baseline defects, you may find the <strong>linked defects</strong> below:</p>
</strong>
${issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Fixes Defect/s")
)}</p>
<p>Once testing is complete, ensure that you update your testing subtask as well as the main ticket status.</p>
<p><strong>Please navigate to </strong><strong><a href="${baseUrl}/browse/${issue.getParentObject()}">${issue.getParentObject()}</strong></a> for all release related artifacts.</p>
<p>Regards,</p>
${issue.assignee?.displayName}
Hi
If I recall correctly the Issue Picker fields that allow multi-selection will return a List of Issue Objects when you get its value.
e.g:
def value = issue.getCustomFieldValue(myField)
So you should be able to get the value of the field, check it is not null and that it is an instance of a list.
e.g:
if(value && value instanceof List){ //logic }
Then you can iterate over all the issues and create a table HTML structure which you can then add to your email template.
It looks like you are using the built-in "Send a custom email" script so it is not easy to do complex logic in the actual email template area. Instead, you can perform the complex logic in the condition and configuration script area and add the created HTML string to the config map variable which is available in the bindings (click the ? on the bottom right of the script field to see bindings). If you add the string to the config bind variable you can refer to it with the standard $ notation in the email template area.
I have an example method that builds a table of issues with links here. Refer to the "buildHTMLTableOfIssues" method
If you still have problems working this out let me know and I can try to draw up a longer example.
Regards
Matthew
Hey there scriptRunner peeps...should I submit a ticket for this or can anyone assist here?
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.