I've successfully created a JIRA rule to send an email notification based on a JQL query. I then applied #IF statement in the email notification to filter by specific fields. During testing I found filtering via #IF only works on core fields, not custom fields.
Below is the script I use. I'm able to filer by status.name, but that same functionality does not apply to issue.customfield_16276.value. I'm looking for a solution to the filtering issue or a workaround to generate the same result. The custom field in this scenario is used in the JQL query just as an FYI. Thoughts?
Development --- this works
{{#lookupIssues}}
{{#if(status.name.startsWith("Development"))}}
<a href="{{url}}">{{key}}</a> {{summary}}
{{/}}
{{/}}
Done --- this works
{{#lookupIssues}}
{{#if(status.name.startsWith("Done"))}}
<a href="{{url}}">{{key}}</a> {{summary}}
{{/}}
{{/}}
Test Alert --- this does not work
{{#lookupIssues}}
{{#if(issue.customfield_16276.value.startsWith("Amber"))}}
<a href="{{url}}">{{key}}</a> {{summary}}
{{/}}
{{/}}
Hi @jalewis -- Welcome to the Atlassian Community!
First thing...When you are inside of an iterator like {{#lookupIssues}} {{/}} you do not use the issue. prefix. That would be trying to reference something outside of the lookup, and so may not work as you expect. Please try removing that to see what happens.
Next, what is the type of your custom field? If it is single selection, you can just check value. However if it is multiple select, you will need to either join all of the values together for the check, or use nested iterators.
If neither of those works, please let me know and we can try some other work-arounds using created variables.
Kind regards,
Bill
Hi Bill, thanks for the reply. I'm still unable to get the JQL results to filter by a custom select field in my example. I removed the issue portion from the script as shown below:
Test Alert --- this does not work
{{#lookupIssues}}
{{#if(customfield_16276.value.startsWith("Amber"))}}
<a href="{{url}}">{{key}}</a> {{summary}}
{{/}}
{{/}}
The custom field is a single selection field with the following values, Green, Amber, Red. Is there a different way to check the value? Maybe something with equals?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Okay, let's confirm the custom field contains what you expect first. Please add an action to write this to the audit log after your lookup issues action:
{{#lookupIssues}}{{customfield_16276.value}}{{^last}}; {{/}}{{/}}
That should produce a list of your custom field values, separated by semicolons. If you see anything else, either the field id is incorrect or it contains something unexpected.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah...something is different with this one, as that "value" may be an object and not a text value. Otherwise it could not possibly display those icons with the data...
Or do your drop-down values contain icons at the front of each value?
If they have the icons, you may want to try endsWith() instead of startsWith()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are the man Bill. I made that change and was able to filter my issues by Amber. Just to recap for anyone following:
Below is the revised code used in the automation email and a screenshot of the final result. Thanks again Bill.
Issues in Development
{{#lookupIssues}}
{{#if(status.name.startsWith("Development"))}}
{{fields.customfield_16276}} <a href="{{url}}">{{key}}</a> {{summary}}
{{/}}
{{/}}
Completed Issues
{{#lookupIssues}}
{{#if(status.name.startsWith("Done"))}}
{{fields.customfield_16276}} <a href="{{url}}">{{key}}</a> {{summary}}
{{/}}
{{/}}
Red Alert Issues
{{#lookupIssues}}
{{#if(customfield_16276.value.endsWith("Amber"))}}
{{fields.customfield_16276}} <a href="{{url}}">{{key}}</a> {{summary}}
{{/}}
{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Awesome! I am glad that worked :^)
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.