Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Number of issue properties using {{issue.properties}}?

Serge Kravchenko August 13, 2024

Hi All,
It looks like {{issue.properties}} smart value returns a JSON object.
I would like to do some list-based operations on these properties, such as getting the number of properties or finding properties that start with a certain substring.
For this, I was thinking of converting {{issue.properties}} from JSON to a list.
Is there a way to do that?
Thank you!

1 answer

0 votes
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.
August 13, 2024

Hi @Serge Kravchenko -- Welcome to the Atlassian Community!

In my experience, some smart value content in automation rules which appears to be JSON or list values is neither of those things.  The only way to know is to attempt to parse them.

Have you tried using list operations on your specific issue property?

If that did not work, have you tried using match() or split() to transform the values into a list?

If you only need the number of properties for a specific issue, perhaps call the REST API endpoint to get the property keys: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-properties/#api-rest-api-3-issue-issueidorkey-properties-get

Kind regards,
Bill

Serge Kravchenko August 13, 2024

Hi Bill, thank you so much for your response!
Yep, I tried using list properties such as size and string methods such as match(). Neither of them worked, so I concluded that the value is a JSON object. :(

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.
August 13, 2024

The match() could be encountering challenges if there are any embedded formatting characters in the content, such as newlines causing the regular expression to halt processing.  One workaround for that is to replace such characters prior to match attempts.

 

Without seeing the specifics of the content in that smart value, I recommend reviewing it to identify where / on-what a split() could be used to produce a list.

Serge Kravchenko August 14, 2024

Hi Bill, I don't think any of these methods are available for a JSON object which {{issue.properties}} seems to return. I tried them, they don't return anything.

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.
August 14, 2024

It is unclear to me of that smart value always contains JSON or if it is plain text.  If it is JSON and contains a list, it should be capable of iteration and list function usage.

I recommend writing the smart value to the audit log, then experimenting by picking text within the result to use with the split() function.

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.
August 21, 2024

Hi @Serge Kravchenko 

Just checking in...were you able to try writing the returned properties to the log to find how to parse them?

To just count them, this seems to work by converting them to text and then splitting.

  • action: create variable
    • name: varIssueProperties
    • smart value: {{issue.properties}}
  • action: write to the log
    • the count is: {{varIssueProperties.split(", ").size|0}}

 

Thanks!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events