Using smart values to get status color

Luc June 9, 2021

Using 'Automation for Jira' version 7.3.3 and I'm trying to get the status color.  According to the following article: https://blog.codebarrel.io/how-to-use-smart-values-in-automation-for-jira-15edddfb8c7c it says that we can get to any attribute following the JSON representation.  So I used the JIRA REST API and was able to see that the statusColor is an attribute in the JSON but when I try and get it back using smart values, I don't get anything.

If I try the following: {{issue.status.statusCategory}}, I get back the following: StatusCategory{self='https://<jiraUrl>/rest/api/2/statuscategory/4', id=4, key='indeterminate', colorName='yellow', name='In Progress'}

I then tried the following: {{issue.status.statusCategory.colorName}} and don't get anything back.  Not even an error.  Is there a limit to the number of indirection that we can do in a smart value?  Am I missing something?

Thanks for your help and time!

Luc

1 answer

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.
June 9, 2021

Hi @Luc 

Full disclosure, I am using Cloud and not Server version of Jira... 

What problem are you trying to solve by capturing the color?  Or is this more a general question about the level of available dereferences in the smart values within automation?

 

For the symptom you observed, this behavior is a known issue and appears to be considered a "documentation problem": https://codebarrel.atlassian.net/browse/AUT-2065

With cloud automation rules, I noted:

  • {{issue.status.statusCategory}} appears to return a JSON object array, and only the name attribute could be dereferenced within a rule.  However the asJsonObjectArray function didn't work either.
  • All other attributes returned null, except...
  • when I used the Cloud action of create variable to first store the value; then I was able to parse out the color using string functions as type-casting appeared to happen:
    • {{varStatusCategory.substringAfter("colorName='").substringBefore("'")}}

So one work-around to try would be to save the value in a text custom field first, re-fetch, and then try to parse it as a string.

Best regards,

Bill

Luc June 10, 2021

Thanks for the info @Bill Sheboy !  Unfortunately, the 'create variable' is only available in the Cloud version and not in the Server version so this option won't work.

The reason I need the status color is that I'm sending an email that contains an HTML table.  I'm trying to set the background cell color based on the status color.  I've gotten around it by doing 2 different rules but was curious as to why I couldn't get the value and save myself 2 rules.

Luc

Like Bill Sheboy likes this
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.
June 10, 2021

Thanks for explaining.  How about this work-around: add a custom field like StatusColor, and set it (hard-coded) whenever an issue transitions.  Then you can use the color in your HTML table when needed in other rules.

__Bill

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
7.13.18
TAGS
AUG Leaders

Atlassian Community Events