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
Any help will be greatly appreciated, thank you
Hi @Allan Conybeare -- Welcome to the Atlassian Community!
The JSON syntax you show is incorrect to set the value of a single-select option field: https://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:
{{issue.timetracking.originalEstimateSeconds.divide(3600)}}
{{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")))}}
{
"fields": {
"customfield_10266": {
"value": "{{varSizing}}"
}
}
}
Please update / adjust the above expressions to match your scenario.
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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\"))){{/}}" } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.