How to return original number value of custom field and the New Value

Jocelyn Aquilina November 2, 2022

Hi everyone,

 

I am trying to automate a part where I have a Parent ticket linked to several child tickets. Now what I want is basically to reflect the number of impacted transactions from the child tickets and the total would add up to the parent. My problem is not knowing how to reflect this whenever a user amends the number within a child ticket. I tried using changelog but no success.

E.g. 1 Parent ticket linked to 1 child ticket, child ticket has 1000 impacted transactions. Therefore Parent also has 1000 transactions. User changes from 1000 to 800, then I would expect the Parent to be changed also.

Tried the following equation basically:

Simple terms: Parent custom field value subtracted from the trigger issue custom field value and added with the new value of the same trigger issue.

Equation attempted which did not work: 

{{issue. customfield_18480}} -{{triggerIssue.changelog.Numbers.customfield_18480.fromstring}} + {{triggerIssue.changelog.Numbers.customfield_18480.tostring}}

 

Would appreciate if someone knows how to work through it or maybe find another way...

2 answers

1 accepted

0 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.
November 2, 2022

Hi @Jocelyn Aquilina -- Welcome to the Atlassian Community!

I noticed a few things with your expression: it has extra spaces around the smart values, the changelog syntax is incorrect, and it is missing the math operator syntax.

Please try this instead, assuming your custom field is a number type:

{{#=}}{{issue.customfield_18480}} - {{#changelog.customfield_18480}}{{fromString.asNumber}}{{/}} + {{#changelog.customfield_18480}}{{toString.asNumber}}{{/}} {{/}}

The changelog smart value is relative to the trigger issue, and so there is no need to add the extra prefix.

Kind regards,
Bill

Jocelyn Aquilina November 3, 2022

Hi @Bill Sheboy !

I just tested it out, and it seemed to not work again.. Checked the audit log and the following screenshot appeared..

Capture.PNG

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.
November 3, 2022

Hi, Jocelyn.

Would you please post an image of your complete rule, including the details of the smart value expression, and the image of the audit log showing all the steps from that rule run?  That may provide more context to explain what is happening.

Thanks!

Jocelyn Aquilina November 3, 2022

Hi @Bill Sheboy !

Please find the image of the audit log showing that rule was executed with some errors. Unfortunately I needed to hide the project behind the ticket numbers...

I will explain in short the rule..

1) Trigger for the rule applies when: Issue is created/edited/transitioned/assigned

2) If Condition: Epic that will be linked to issue exists

3) Branch Rule: For the Epic (Parent)

4) Edit the issue field for the Epic.

Capture1.PNGCapture.PNG

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.
November 4, 2022

Thanks for that information, @Jocelyn Aquilina 

 

What is the type of your custom field: text, number, single-select, etc.?

 

And, let's add some diagnostic checks to help see what is happening...After your trigger, please adding three writes to the audit log using Log Action containing each of these values.  Then run the rule and post what the audit log shows:

Custom field is: {{issue.customfield_18480}}
The from value is: {{#changelog.customfield_18480}}{{fromString.asNumber}}{{/}}
The to value is: {{#changelog.customfield_18480}}{{toString.asNumber}}{{/}}
Jocelyn Aquilina November 6, 2022

Hello @Bill Sheboy !

This custom field is a simple Number Field. I will try this suggestion soon as I am very new at this! Thanks!

Jocelyn Aquilina November 7, 2022

Would you be able to show me with screenshots on how to insert these into the audit logs?

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.
November 7, 2022

After the trigger in your rule, select Add Component, and then select the one for Log Action, such as below:

Capture.PNG

Select Save, and do the same thing for the other two smart value entries.

Then run your rule, observe the audit log details, and post an image of what you observe.

Jocelyn Aquilina November 7, 2022

Hello @Bill Sheboy !

Thank you for explaining, the logging action worked. Please find the screenshot as requested. It seems the old and new values of the trigger ticket are not being picked up..

Log Action.PNG

Jocelyn Aquilina November 7, 2022

By the way, I changed the value from 100 to 200 in the trigger issue.

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.
November 8, 2022

Just to clarify, are you saying your field edit changed the field from 100 to 200, and the log of the value instead shows 250.0?

In that case, I suspect you have the wrong field's custom field id (or that it is a calculated field from an addon app and so may not be supported).

Let's try this, based on this how-to article to identify your smart value: https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/

  1. Identify the issue key for that one you just edited.  For example MYPROJECT-5469
  2. Identify the url for your Jira site, yourJiraUrl
  3. In a new browser tab, enter a url to query the issue's fields: https://yourJiraUrl/rest/api/2/issue/MYPROJECT-5469?expand=names
  4. On the page, search for the Name of your field, and note the custom field id.  That is the one to use in the rule
  5. If the field is not present, then your field is not supported in automation rules
Jocelyn Aquilina November 8, 2022

Hi @Bill Sheboy !

 

Custom field number is definitely correct. With regards to the number part, I edited the number from 100 to 200 on the trigger issue and the 250 is the original number left on the Epic ticket. What this means I was supposed to be seeing an increase of 100 in the Epic, taking the total to 350.

 

Could it be that we need to refer to the trigger issue's custom field within the "The from value" and the "The to value" within the equations you provided?

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.
November 9, 2022

The changelog smart values only refer to the changes in the trigger issue, so no rule confusion there.

Would you please post an image your current, entire rule?  That may provide context in case we are missing something about the rule structure.  Thanks!

Jocelyn Aquilina November 9, 2022

Hi @Bill Sheboy !

The entire rule is here:
Capture.PNG

 

The "When" part is basically: the following.

Field Value.PNG

The rest of the rule is only a condition that if the Epic simply exists and the Edit part for now is the latest one that you suggested to insert as the equation before the logging action part.

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.
November 10, 2022

In your screen image of the Edit Action, the smart value has extra spaces and some extra syntax.

For example, you have:

{{issue. customfield_18480}}

There should not be a space after issue.

And I see

{{triggerIssue.changelog.Numbers...

As I noted earlier, the changelog smart value can only apply the trigger issue, and so you do not need that in the expression.  Instead use this:

{{#changelog.customfield_18480}}{{fromString.asNumber}}{{/}}

 

If that does not help, I suggest working with your site admin to submit a ticket to Atlassian Support at the link below.  They may be able to see something we are missing to make this work.  https://support.atlassian.com/contact/#/

Jocelyn Aquilina November 11, 2022

Hi @Bill Sheboy

Thank you for your help, will keep trying and take it up with my site admin maybe some part of my project is "off".

 

Best regards,

Jocelyn

Like Bill Sheboy likes this
0 votes
Jocelyn Aquilina November 2, 2022

Forgot to mention. JIRA version is v8.22.6

Capture.PNG

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events