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}}{{/}}
Step 2: Convert diffday to hours and store it in the log work field.
smart values: {{#=}}{{diffday}} * 8{{/}}h
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}}
I try many way but seem it not work. This log show bellow
I'm using Jira v9.12.10
Please help me
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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){{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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}}{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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}}) {{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please show us the exact text you are using. A screen image would be ideal.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.