Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira smart values for custom fields within a branch...

Marc Isikoff
Contributor
November 17, 2023

The main context of this ask, is the lack of Data/Time fields in Jira for when an SLA is met within Service Management. We require knowledge of the date/time for reporting.

So we created 2 date/time fields for SLAs: TTR (time to resolution) and TFR (time to first response) and we give them {{now}} in 2 sets of automation for when the SLA is satisfied.

Note there is no trigger for SLA satisfied, only for SLA breach. So we have to mirror the actions:

1. For SLA TTR is met - trigger when resolution is entered and issue transitioned to Resolved is fairly easy to set {{now}} to the TTR custom field.

2. For SLA TFR is met - the trigger is on comment made as the SLA is met with the assignee first responds to the customer. This is the harder one:

We need the right smartvalue for within a Branch on 'current issue.'

Branch on current issue fires for the issue tripping the automation when and issue comment is made.

We then branch "For Current Issue" (e.g., the one where the comment was just made)

Within the branch I want to make sure of 4 facts before applying an edit to the issue:

1. The customer request type is one where we have SLAs

2. The TFR met date/time field is empty (we don't want to overwrite with each comment)

3. The comment author is the assignee

4. The comment not internal

Results:

Condition 1: Easy as a field comparison on customer request type.

Condition 2: Fail: We have tried to use JQL in the branch with {{triggerissue.customfield_123456}} is EMPTY --> gives error "(key in ([jiraproject-key#]) AND (is EMPTY)). Expecting a field name but got 'is'. You must surround 'is' in quotation marks to use it as a field name.

So clearly the problem is not 'is' but the smartvalue is not resolving so is null.

That is where we are stuck.

 

Note: Server/Data Center in our own cloud, not Atlassian's.

2 answers

1 vote
Bill Sheboy
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.
November 17, 2023

Hi @Marc Isikoff 

For a question like this, please post an image of your complete automation rule, images of any relevant actions / conditions / branches, and an image of the audit log details showing the rule execution.  Those will provide context for the community to offer ideas.  Thanks!

Until we see those...

That error message indicates the smart value / field in the JQL collapsed to null, leading to a different JQL error.

Two things to try are:

Smart values are name, spacing, and case-sensitive.  The one for the trigger issue is {{triggerIssue}} and so please try updating to use that as the case in your rule is different.

Next, to confirm if your fields are supported in rules, and what the smart values are, please try this how-to article: https://confluence.atlassian.com/automation/find-the-smart-value-for-a-field-993924665.html

Essentially you find an example issue with your fields, call a REST API function to load the issue, and then search on the page for your fields, such as with CTRL-F.  If you do not see your field, it is not supported by automation rules.  If you find it, please check the smart values used.

Kind regards,
Bill

Marc Isikoff
Contributor
November 17, 2023

Bill,

Thanks; however I cannot post images per company rules.

For sure there is no spelling issue and I have the right field which is available in.

I suspect I could move this condition into an Advanced compare Condition and put {{triggerissue.customfield_123456}} as the First Value, the Condition set to Equals and the Second Value put to Null and try that.

Bill Sheboy
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.
November 17, 2023

If you cannot post images, perhaps list all of your rule steps using bullets, adding details for the smart values...and copy/paste in the text from the audit log details.  I know that is a pain...but context is key for solving rule problems.

 

Updates after some testing with a date/time field

(A) When the field was never set, such as for a new issue, the following correctly detected the empty field:

  1. basic Issue Fields Condition with "is empty"
  2. advanced compare condition, entering the field in first value, condition is "equals", and leave the second value empty
  3. advanced compare condition, with a conditional expression
  • first value: {{#if(not(exists(issue.customfield_10066)))}}is empty{{/}}
  • condition equals
  • second value: is empty

 

(B) When the field was filled in with a date/time value, all the methods (1-3) correctly detected the field was not empty.

(C) When the field was cleared back to empty, all the methods (1-3) correctly detected the field was empty.

 

Marc Isikoff
Contributor
November 20, 2023

@Bill Sheboy 

Progress but one issue remains.

First: This accepted the JQL for: {{#if(not(exists(issue.customfield_12345)))}}is empty{{/}}

Second: This correctly handled "who" did the comment: {{triggerissue.comments.last.author}} not equal {{triggerissue.reporter}}

The issue: {{triggerissue.comments.last.internal}} equals false is not working and says it does not match the condition.

The last step is to make sure it's not an internal issue, but one we are indeed letting the reporter know.

Bill Sheboy
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.
November 20, 2023

Do you have Jira Service Management?  According to the documentation, the internal attribute only works when that is installed.

https://confluence.atlassian.com/automation/jira-smart-values-issues-993924860.html

0 votes
Jonathan Tang November 17, 2023

Marc,

For item 2's Smart Variable, you might see if an inline if/else statement works to evaluate NULLs and replace it with something workable:

I use this when implementing a new field and need to account for older projects/tickets that may not have any values associated.

{{#if(equals(issue.customfield_1xxxx.value, NULL))}}yourTextHere{{/}}
Marc Isikoff
Contributor
November 17, 2023

Jonathan,

 

Thanks for that, but I cannot put {{now}} in until I know 3 things:

1. The field is already empty

2. The comment was from the assignee

3. The comment was not internal

Suggest an answer

Log in or Sign up to answer