Forums

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

Automation for Jira - Set issue property writes the value as a string

Simon H
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.
February 13, 2020

Update: There are two issues. One is being unable to write a JSON object using the set entity property. The other is that you cannot retrieve the entity property as a JSON object, it is returned as a string see AUT-1696.

We are attempting to copy an entity property from a parent issue to a subtask. Everything is working as expected; however, when we use the Set issue property it writes the values as a string and adds quotation marks around the json we are adding, which makes the JSON invalid. 

Is this a bug or is there some work around?

The automation rule we have created is:

image (15).png

 

The result is this

image (16).png

2 answers

0 votes
Darryl Lee
Community Champion
November 2, 2020

Hey all - has anybody tried this lately?

As recently as last week, I was able to "extract" values out of a project property that looked like this:

{
"engineering-approver-primary": "someaccountid",
"engineering-approver-secondary": "someotheracccountid",
"build-approver-primary": "thisaccountid",
"build-approver-secondary": "thataccountid"
}

My trick was using a web request to get the data out, and into {{webhookResponse.body}}, where I was then able to use {{webhookResponse.body.value.engineering-approver-primary}} to update a User field.

I had to use a web request because there is no way to currently reference (evaluate/nest) a smart value within a smart value.

Like, I ideally I'd be able to simple update a field by doing:

{{project.property.{{issue.component.value}}.value.engineering-approver-primary}}

But that's not a valid Smart Value.

Darryl Lee
Community Champion
November 2, 2020

Oh, but to Simon's original message, it seems like I *was* able to write a valid JSON object using the set entity property. At least it was valid enough for it to be properly parsed as a {{webhookResponse.body}}.

I set the Property value above using this code:

{
   "engineering-approver-primary": "{{issue.Engineering Approver Primary.accountId}}",
   "engineering-approver-secondary": "{{issue.Engineering Approver Secondary.accountId}}",
   "build-approver-primary": "{{issue.Build Approver Primary.accountId}}",
   "build-approver-secondary": "{{issue.Build Approver Secondary.accountId}}"
}
Like # people like this
Darryl Lee
Community Champion
November 2, 2020

So I'm guessing for you, @Simon H, it's the {{issue.parent.properties."proforma.forms"}} that's introducing the extraneous quotation marks.

I think Automation could really use the inverse (converse?) of the asJsonString function.

> stringAsJson or something would attempt to parse a string into a JSON object.

Or they could just recognize a JSON object and return it appropriately. :-P

Like James D likes this
0 votes
Martin Cleaver
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 28, 2020

Simon - yes, I've been telling Atlassian that A4J's JSON handling is broken.

I assume you didn't find a solution (?)

Did you email support? We can't vote on issues on the old codebarrel site, so at least this adds context and pressure on them.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events