Forums

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

Using smart variable for creating issue with Jira automation

Zsigmond Molnar January 26, 2025

Hi,

 

I would like to create issues with Jira automation and set their attributes based on the content of a variable (myVariable).

 

myVariable is created at the beginning of the automation rule and set to:

 

{

"epic": {

"epicname": "audit finding",

"summary": "audit finding",

"assignee": "XY"

},

"stories": [

{

"summary": "Update document #1",

"status": "Backlog",

"duedate": "30/Apr/25"

},

{

"summary": "Update document #2",

"status": "In Progress",

"duedate": "30/Apr/25"

},

{

"summary": "Update document #3",

"status": "To Do",

"duedate": "30/Apr/25"

}

]

}

 

During the creation of the epic and stories I wanted to set the attributes as follows:

{{ myVariable.epic.summary}}

{{ myVariable.stories[0].summary}}

 

Both of them are empty, therefore the issue creation failed.

 

Could you please tell me how can I use the fields of the JSON format variable to set the attributes of the issues in Jira automation rule?

 

Thank you in advance for you help!

2 answers

1 accepted

3 votes
Answer accepted
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.
January 26, 2025

Hi @Zsigmond Molnar 

Short answer: a created variable is plain text and cannot be parsed as JSON.  Here is a suggestion to add that feature: https://jira.atlassian.com/browse/AUTO-138

 

If you want to store the information you show in a created variable, text and list functions would be needed to parse it, and possibly use the advanced branch to iterate over any lists of values (e.g., the Story information you show).

Another option is ignore the variable and the rule could instead just call the create issue actions to set the fields.

If instead you eventually plan to get that text / data from a REST API call with the Send Web Request action (or Incoming Webhook Trigger), the data might be in a JSON format with attributes which can be parsed.

 

Kind regards,
Bill

Zsigmond Molnar January 26, 2025

Hi @Bill Sheboy,

Thank you for your quick answer!
I'm going to implement the proposed solution.

I tried to use the jsonStringToObject() function.
The first row returns the proper value, but the second function doesn't return anything.
Is it a wrong approach?

{{jsonStringToObject(variableIssueProperty).epic.summary}}
{{jsonStringToObject(variableIssueProperty).stories[0].summary}}

 

Kind regards,

Zsigmond

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.
January 26, 2025

Please use the get() function to access a list element within an automation rule (or use an iterator or branch).

For example:

{{jsonStringToObject(variableIssueProperty).stories.get(0).summary}}

 

Like Zsigmond Molnar likes this
0 votes
Zsigmond Molnar January 26, 2025

Hi Bill,

Thank you for your help!
The solution you suggested works perfectly.

 

Kind regards,

Zsigmond

RKE2
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 28, 2025

Using smart variables in Jira automation is such a powerful approach. It is really streamlines workflows and makes issue creation more dynamic and customizable.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
AUG Leaders

Atlassian Community Events