Adding 2 values using Smart Values in an automation
Asked by Anthony Esslinger:

I am trying to add 2 smart values and then divide it by 2 to set a 3rd field value. I am using the following to try and just add the 2 numbers but it isn't working:

{{#=}}{{issue.Person Priority}} + {{issue.Issue Priority}}{{/}}

I would think that if this worked I could divide by 2 using this

{{#=}}{{issue.Person Priority}} + {{issue.Issue Priority}} / 2{{/}}

but with the Person Priority being 4(set by previous automation) and Issue Priority being 4(set by Post function), the Dynamic priority set by the above smart values = 4 instead of 8.

Any help would be greatly appreciated.


Answers:
author: Trudy Claspill
body: Hello [@Anthony Esslinger](/t5/user/viewprofilepage/user-id/2363850)

Is this in the context of an Automation Rule? If so, please provide screen images that show the entire rule and details of each step. Also please provide the details from the rule execution audit log.

> I am trying to add 2 smart values and then divide it by 2 to set a 3rd field value. I am using the following to try and just add the 2 numbers but it isn't working:
>
> {{#=}}{{issue.Person Priority}} + {{issue.Issue Priority}}{{/}}

How are you determining that it isn't working?

Are you validating that {{issue.Person Priority}} and {{issue.Issue Priority}} are numeric fields that each contain a value?

> {{#=}}{{issue.Person Priority}} + {{issue.Issue Priority}} / 2{{/}}  
>
> but with the Person Priority being 4(set by previous automation) and Issue Priority being 4(set by Post function), the Dynamic priority set by the above smart values = 4 instead of 8.

Are you saying the final value from that calculation is 4, and you expect it to be 8? 4 seems to be the correct value:

4 + 4 / 2

4+4 = 8

8 / 2 = 4

I recommend that you make liberal use of the[Log action](https://support.atlassian.com/cloud-automation/docs/jira-automation-actions/#Log-action) in your rule to print to the rule execution log the value of each smart value you are using.

comments: author: Anthony Esslinger
body: I am using the first calculation {{#=}}{{issue.Person Priority}} + {{issue.Issue Priority}}{{/}} and it returning 4 when it should be 8


author: Trudy Claspill
body: I recommend that you use the Log action in your rule to print into the rule execution log those two smart values immediately before the step where you do that calculation. I suspect that will reveal those smart values are not what you expect them to be.

For additional help we will need you to provide screen images showing the entire rule and the details of each step.


author: Anthony Esslinger
body: How do i get the audit log to show me the values it is taking for the 2 smart values?


author: Anthony Esslinger
body: ![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/344940i54BF9CB4A7D379DF/image-size/large?v=v2&px=999 "image.png")


author: Anthony Esslinger
body: ![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/344941i9D4964C02F71EAE9/image-size/large?v=v2&px=999 "image.png")


author: Anthony Esslinger
body: The delay is to insure that the Person Priority and Issue Priority are filled before the next automation tries to add the 2 fields


author: Anthony Esslinger
body: ![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/344942i333B1E5DC64BD9CE/image-size/large?v=v2&px=999 "image.png")


author: Anthony Esslinger
body: Those are the steps of the automation


author: Trudy Claspill
body: As I mentioned you can use the Log action to write information into the Audit Log. You can find info on that action in the documentation for Actions.

<https://support.atlassian.com/cloud-automation/docs/jira-automation-actions/>

You can fill in the Log action withe explicit text and smart values such as

Person priority: {{issue.Person Priority}}

That will print the literal text

Person priority:

and the value of the smart value.


author: Anthony Esslinger
body: ![Person priority.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/346165iFAD89CFC08A0C5B8/image-size/large?v=v2&px=999 "Person priority.jpg")


author: Anthony Esslinger
body: So I set up 3 comments to show the Person Priority. One happens when the ticket is created, next happens 3 seconds later and the 3rd happens after an additional 10 seconds. In all cases it shows that {{issue.Person Priority}} is empty but the value of the Person Priority shows up in the ticket as 3.5 as soon as the ticket is created. It just doesn't make sense, I don't know what I am doing wrong.


author: Trudy Claspill
body: Please provide images showing your current rule and details of each step, since you have modified it.

You may want to try adding a Re-fetch Issue action to you rule, after the trigger. Sometimes the trigger happens before all data has been saved. The Re-fetch Issue action will re-query Jira to get the current data.

You can find the action described in the documentation.

<https://support.atlassian.com/cloud-automation/docs/jira-automation-actions/>

On a side note, you don't need to write the information in an Issue Comment. You can use the Log action I mentioned previously to write the information into the rule execution log. Adding comments can cause notifications to be sent to individuals related to the issue, which may be undesirable.


Tags: cloud

cloud-automation

jira-service-management

jira-service-management-cloud