Subtract the value of one custom field from the value of another custom field

Razinov V_N_ February 28, 2024

Hello community.

Today I am faced with such a problem. It is necessary to subtract the value of one custom field, customfield_10251, which is located in the linked task from the value of another custom field, customfield_10249, which is located in the parent task.
Field type is the same = Number Field
There are no errors when executing the automation rule, but the result is incorrect

{{#=}} {{issue.parent.fields.customfield_10249|0}} - {{issue.fields.customfield_10251|0}} {{/}}

value in field 10249 = 6 10251 = 3 (for example)

Screenshot 2024-02-28 at 11.51.55.pngScreenshot 2024-02-28 at 11.52.17.pngScreenshot 2024-02-28 at 11.52.50.pngPerhaps someone can help me solve this problem

2 answers

1 accepted

0 votes
Answer accepted
Razinov V_N_ February 28, 2024

Use this code

{
"update": {
"customfield_10249": [
{
"set": {{#=}}{{issue.fields.customfield_10249|0}} - {{triggerIssue.fields.customfield_10251|0}}{{/}}

}
]
}
}

0 votes
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.
February 28, 2024

Hi @Razinov V_N_ 

When using automation rules to access linked issues, such as the parent of an issue, all of that parent's fields are not immediately available.  There is some subset of the fields directly available for the parent, such as key, summary, status, etc. but not all custom fields.

The reason is one of scale and looping: pulling in all of the parent (or linked issues) fields, would then pull in all of their linked issues, and their fields, and so on.  And as many links are bi-directional, this would also lead to loops.

 

When you want to access those other fields in the parent, the two options are to use a branch or Lookup Issues action with JQL to load the parent data.  For your scenario, I recommend using lookup issues.

 

Kind regards,
Bill

Suggest an answer

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

Atlassian Community Events