Forums

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

Created variable not being expanded/substituted in JIRA automation - rookie mistake?

Hugh Kelley
Contributor
June 5, 2023

I have added a custom variable to the first step of my automation,

Smart Value of variable (which worked fine when I used it directly in the HTTP step):

 postBody = {{issue.comments.last.body}}

When I try to use this variable {{postBody}} in the later Web Request step, I get nothing.

{
"jirakey":"{{issue.key}}"
,"statusid":"{{issue.status}}"
,"statuscode":"{{issue.status.name}}"
, "externalref":"{{issue.Ext Ref}}"
, "author":"{{issue.comments.last.author.emailAddress}}"
, "note":"{{postBody}}"
}

Example from Validate:

{
  "jirakey": "SCM-227",
  "statusid": "10001",
  "statuscode": "Done",
  "externalref": "436976",
  "author": "xxx@yyyy.com",
  "note": ""
}

 

1 answer

0 votes
Trudy Claspill
Community Champion
June 5, 2023

Hello @Hugh Kelley 

Can you show us the entire automation rule, please?

Sometimes problems like this are related to the context where the smart value is being referenced. The creation of the variable may be out of scope compared to where you are trying to use the variable.

Hugh Kelley
Contributor
June 5, 2023

I've uploaded pics.  If there's a cleaner way to show it (JSON or XML) then I'm happy to learn that.

 

My issue seems similar to the one in Using-variables-in-functions-in-smart-values-in-JIRA  where the variables don't seem to be usable.

var.JPGoverall.JPG

 

Hugh Kelley
Contributor
June 6, 2023

I think the issue is that the variable (from a previous step) is not set when the Send Web Request Validate option is used.   If I add comments using a real issue, the variable seems to work as expected.

Trudy Claspill
Community Champion
June 6, 2023

Can you add a Log action to print the value of the variable to the rule audit log? Add it after creating the variable and before the web request step. This will confirm that the variable has a value.

Is there a reason you aren't using {{issue.comments.last.body}} in the web request?

Suggest an answer

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

Atlassian Community Events