Display JQL Result in Custom Email Postfunction

Francisco Ayala Bocardo December 20, 2017

Hi,

I would like to know if it's possible to send a JQL result and extract custom field values from the results using the 'Send Custom Email' post function.

Business Case:

One ticket will track a business workflow and this will trigger several emails along the workflow. However there are certain post function emails that have to be tailored based on a JQL result.

So the goal is to display the JQL result as a table in the email template with specific custom fields as the columns and the issues as the rows, basically what you can do when you search for issues in JIRA, and define the 'To'/'CC' based on custom fields from the issues that are a result of the JQL.

Currently I use this post function for other applications that involve only information from the ticket that is being used to generate the email and I have no issues with this case. However I would appreciate to see if my scenario is possible or not, and if possible to have some assistance in how to achieve it. 

Thanks,

Francisco

2 answers

0 votes
Francisco Ayala Bocardo December 21, 2017

Hi Ignacio,

A subscription to a filter kind of covers the display of the required custom fields for the desired JQL, however it does not cover the need of having a customized list of recipients which is the goal. Based on the results from the JQL, certain emails will be obtained for the resulting tickets (assignee, custom field 1, custom field 2, etc.), hence the email won't be sent to a fixed group(s), but a variable one depending on the JQL result.

Thanks

Ignacio Pulgar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 21, 2017

Hi Francisco,

Filter subscriptions execute the filter's query one time for each user subscribed to it as if executed by such user.

This means that you can still cover your needs subscribing a large group of users (jira-users?) to a filter which includes something like:

(assignee=currentUser() OR cf[1]=currentUser() OR cf[2]=currentUser())

Just ensure you keep unchecked the checkbox 'Email this filter, even if there are no issues found':

subscription.png

Of course, if you could narrow the group of users to any other group(s) smaller than jira-users, it would be better.

As you were expecting the email to be sent during a transition, you may want to represent that condition in your filter by adding a JQL fragment similar to this one:

...AND status changed FROM 'In Progress' TO Done AFTER -15m...

Hope it helps.

Francisco Ayala Bocardo January 2, 2018

Hi Ignacio,

Appreciate the suggestion, however having a fixed group is what I am trying to avoid. The reason is that the items in the query will be different every week, therefore changing the audience I want to notify. The audience will always be stakeholders from the specific tickets in the query result, so I just want this set of users to receive the email. 

i.e. Week 1 has a query with Tickets 1 - 5 with Persons A - E, so I just want the email to be sent to Persons A - E, not a fixed group that will contain Persons A-Z. 

Thanks for the help, if there is no way to accomplish what I am trying to do, I will definitely follow your suggestion. 

Regards,

Francisco Ayala

0 votes
Ignacio Pulgar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 21, 2017

Hi Francisco,

The functionality you are describing seems to be better covered by a filter set to show the custom fields of your choice, subscribing to it afterwards.

Note this is JIRA native functionality so, if you can stick to it, you will avoid getting technical debt.

Besides, sending the email immediately with the filter subscription approach can also be triggered by a mouse click on Run Now:

run-now.png

Do you think this can work for you? If that's not the case, why?

Suggest an answer

Log in or Sign up to answer