Forums

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

Jira Automation - Setting Customfield Based on Conditional Logic

Allan Conybeare
Contributor
March 28, 2025

 

 

In Jira automation I am trying to write some conditional logic to set a custom field (T-Shirt Size) based on the value in Original Estimate in the Additional Fields part of Edit issue and need a bit of help please.

I'm using a "Value Changes for" trigger on Time tracking and am successfully trapping when the original estimate is set or changes, added a screenshot of my rule below.

The field that I'm trying to set is a select drop down although I don't think I'm getting near that point yet. This is what I have so far -

{ "fields": { "customfield_10266": "{{#=}}if(issue.fields.originalEstimateSeconds.lte(288000), \"S\", if(issue.fields.originalEstimateSeconds.lte(864000), \"M\", if(issue.fields.originalEstimateSeconds.lte(1440000), \"L\", \"XL\"))){{/}}" } }

 

Error -

 

Error while rendering additional fields.
Unknown operator . at character position 9

 

JiraAutomationHelp.png

 

Any help will be greatly appreciated, thank you

3 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.
March 28, 2025

Hi @Allan Conybeare -- Welcome to the Atlassian Community!

The JSON syntax you show is incorrect to set the value of a single-select option fieldhttps://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/#Single-select-custom-field

 

Next, the logic you are attempting will require using upper and lower limits for each value, such as using the and() function within nesting of the longer form of the if() function:

 

Next, your smart value for the time tracking field is incorrect.  It should be:

{{issue.timetracking.originalEstimateSeconds}}

 

Finally, you want to use the value within JSON, and so the quotation marks within the nested if() functions will not work correctly.  The workaround for that is to first determine your "sizing" value and store that in a created variable, and then use that in the JSON expression.  I also recommend converting to hours first to make maintenance / testing easier.

 

For example:

  • action: create variable
    • name: varHours
    • value:
{{issue.timetracking.originalEstimateSeconds.divide(3600)}}
  • action: create variable
    • name: varSizing
    • value:
{{if(varHours.asNumber.lte(80), "S",
if(and(varHours.asNumber.gt(80), varHours.asNumber.lte(240)), "M",
if(and(varHours.asNumber.gt(240), varHours.asNumber.lte(400)), "L", "XL")))}}
  • action: edit issue, with the dynamic JSON expression
{
"fields": {
"customfield_10266": {
"value": "{{varSizing}}"
}
}
}

Please update / adjust the above expressions to match your scenario.

 

Kind regards,
Bill

Allan Conybeare
Contributor
March 28, 2025

@Bill Sheboy, awesome that's worked!

Thanks very much!!

Like Bill Sheboy likes this
1 vote
Trudy Claspill
Community Champion
March 28, 2025

Hell0 @Allan Conybeare 

Welcome to the Atlassian community.

While I can't say if the logic you have built will work as you expect, I can say that I have copied the exact code you provided into an Edit Issue step in my own rule and I don't get an error when I save the rule.

Perhaps try replacing the existing step with a new Edit Issue step and copy the text from your post here into the new step.

Allan Conybeare
Contributor
March 28, 2025

Hi Trudy, thanks for your reply, I've done as you suggested but getting the same error. I get the error when it runs, it saves okay with a note saying -

"We can't validate your smart value until the rule runs. Check the audit log after the rule runs to ensure it was successful."

I'm pulling the error message out of the audit log.

1 vote
Ashish Gupta
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 28, 2025

Hello @Allan Conybeare,
Good Day!

The error message you're seeing, "Unknown operator . at character position 9," suggests that there might be an issue with the syntax or the smart values used in your automation rule.
To handle potential null values, use the nullish verifier to set a default value. This ensures that your calculations proceed even if the original estimate is not set. Can you try the below format and test the results? 

{ 
  "fields": { 
    "customfield_10266": "{{#=}}if(issue.fields.originalEstimateSeconds|0 <= 288000, \"S\", if(issue.fields.originalEstimateSeconds|0 <= 864000, \"M\", if(issue.fields.originalEstimateSeconds|0 <= 1440000, \"L\", \"XL\"))){{/}}" 
  } 
}  

 

Allan Conybeare
Contributor
March 28, 2025

Thanks for your reply, I've added your changes in and retested, got the same error, my test issue has an estimate value - 

Error while rendering additional fields.
Unknown operator . at character position 9

Suggest an answer

Log in or Sign up to answer