Forums

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

Jira smart values for custom field: calculate and log work not working

toannv26
December 14, 2025

I define a rule to auto log work when user change effort value.

Step 1: Calculate the diffday difference when the developer actual effort field (customfield_19616) changes by subtracting the old value (stored in the customfield_10303 field.because fieldchange.from.value cannot be used). The unit of this field is days.

smart values:
{{#=}}{{issue.fields.customfield_19616.diff(issue.fields.customfield_10303).abs}}{{/}}

rule.png

Step 2: Convert diffday to hours and store it in the log work field.
smart values: {{#=}}{{diffday}} * 8{{/}}h


logwwork.png

Step 3: Store the value of the developer actual effort field in the program_id field to calculate the difference next time.

Smart Value:
{{issue.fields.customfield_19616}}

programid.png

I try many way but seem it not work. This log show bellow
I'm using Jira v9.12.10


log.png

Please help me

3 answers

1 accepted

0 votes
Answer accepted
toannv26
December 17, 2025

Hello @Trudy Claspill , @Bill Sheboy , @Duc Thang TRAN 
I found the correct rules for this case. Because the value seem have special character, so can't using math function directly.

This is my worked rule: 
{{#=}}{{issue.customfield_19616.plus(0)}} - {{issue.customfield_10303.match("(\d+\.?\d*)")}}{{/}}

Thank you all for support

Duc Thang TRAN
Contributor
December 18, 2025

Hello @toannv26 

Indeed, if you have a free-text field and people enter characters other than numbers, this is normal .astext retrive error 

For my suggestion , it is better to use a date field and let the smart value handle the difference, which helps avoid errors when inserting data

 

0 votes
Duc Thang TRAN
Contributor
December 15, 2025

Hello @toannv26 

Can you try this smart value if you need diff business days ?
{{#=}}{{issue.fields.customfield_11206.diff(issue.fields.customfield_11256).businessDays.abs}}*8{{/}}

If only need diff day

{{#=}}{{issue.fields.customfield_11206.diff(issue.fields.customfield_11256).days.abs}}*8{{/}}

Hope this can help

toannv26
December 15, 2025

customfield_19616 type float, customfield_10303 type text
It not a date field. So I think .days or .businessDays will not working

Duc Thang TRAN
Contributor
December 16, 2025

Hello @toannv26 

When I suggest this, I think you used beetwen two date fields.

If one is a float or text field, you can try this one: {{#=}}(ABS({{issue.fields.customfield_19616}} - {{issue.fields.customfield_10303}})*8){{/}}

0 votes
Trudy Claspill
Community Champion
December 14, 2025

Hello @toannv26 

Welcome to the Atlassian community.

I suspect there may be a problem with your use of the diff function in the math expression you use when creating your {{diffday}} variable.

Can you add a Log action after creation of that variable to log the value of it?

Screenshot 2025-12-14 at 9.58.33 PM.png

I suspect this is the case because no value is being shown for the variable in the error message in your log. Instead it is detecting the "*" as the first character in that match expression.

Screenshot 2025-12-14 at 10.01.56 PM.png

 

I think instead of the diff function you need to use the unary minus operator to subtract one value from the other.

Disclaimer: I don't have a Data Center environment where I can test this out, so this is an untested recommendation.

toannv26
December 14, 2025

@Trudy Claspill Thank you for your support. I think you are right about diff value issue. I change to minus operator but it still not working
Screenshot 2025-12-15 131728.png

diff.png

Trudy Claspill
Community Champion
December 15, 2025

What are the custom fields types for 19616 and 10303?

Consider logging the values of those fields, and the math expression from your Create Variable, into the audit log to see if you are getting the expected values

toannv26
December 15, 2025

@Trudy Claspill 
customfield_19616 type float, customfield_10303 type text
I try to convert text tonumber but not working


{{#=}}{{issue.fields.customfield_19616 - issue.fields.customfield_10303.asNumber}}{{/}}

Trudy Claspill
Community Champion
December 16, 2025

Looking at the examples shown here:

https://confluence.atlassian.com/automation/jira-smart-values-math-expressions-993924866.html

...You should not have a set of curly braces around the entire expression. Instead it appears that field references within the expression need to each be enclosed in double-curly braces.

And if you want to apply the ABS function you would put that first and the field subtraction part of the expression in the parentheses

 

{#=}} ABS({{issue.fields.customfield_19616}} - {{issue.fields.customfield_10303.asNumber}}) {{/}}

 

toannv26
December 17, 2025

Still not working
Error: Error parsing template: Mismatched start/end tags: null != in template-f9a653e5-bd4c-4de6-ab68-a915513883e1:1

Trudy Claspill
Community Champion
December 17, 2025

Please show us the exact text you are using. A screen image would be ideal.

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 Champions.
December 17, 2025

Hi @toannv26 and @Trudy Claspill 

I do not believe the asNumber function exists for Jira Server or Data Center automation rules.  Instead, please use the math expression and allow it to automatically convert the value:

{#=}} ABS( {{issue.fields.customfield_19616}} - {{issue.fields.customfield_10303}} ) {{/}}

And, please consider adding the ROUND() function to reduce the chance of other problems with the later use of the Log Work action.

 

Kind regards,
Bill

Like Trudy Claspill likes this
Trudy Claspill
Community Champion
December 17, 2025

Thanks @Bill Sheboy . I was trying to ascertain if it was and have not been able to find a definitive answer. I saw several community post where it was included in answers that were accepted, where the author said the problem was solved, and the tags indicated the post concerned server/DC.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events