Trying to update a field with Automation that mostly works
Asked by Bobby Williams:

EDITED to update the problem:

I am using some automation rules documented on this site to update my Epic value for {{worklog.timeSpent}}.

It DID NOT work as shown in several submissions in my Cloud environment.

The accepted answer is actually to get the rules to work to update the Epic Values.

I will open a new question about calculating my "% Complete" custom field, if I have additional questions related to that.

BELOW IS NO LONGER RELEVANT TO THIS QUESTION.

Since that worked, I am now trying to update another field (custom field that I created) called "% Complete". I realize that there is a % done field, but it uses tasks completed instead of time.

Anyway, I am not getting the syntax correct on the math. Can someone help me with the syntax?

{{#=}} ( {{worklog.timeSpent}} \* 100 ) /

( {{timetracking.originalestimate}} - {{worklog.timeSpent}} ) {{/}}


Answers:
author: Bobby Williams
body: After getting my Epic work log to work, I focused on getting my custom field "% Complete" to update.

This is only triggered now on a comment update as I was troubleshooting the syntax. I will put the correct trigger in place (or maybe cron) to initiate.

The Add value to the audit log has the calculation.

The Add to ![Rule to Update % Complete calculations.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/324300iCA7A11F386B10870/image-size/large?v=v2&px=999 "Rule to Update % Complete calculations.jpg")


author: Bobby Williams
body: I got the Epic work log script to work by using 2 scripts.

They are pretty much identical, with one being initiated by a sub-task to update the work log on the parent story.

The other being initiated by the story to update the work log on the parent Epic.

The story initiated rule has "Check to allow other rule actions to trigger this rule. Only enable this if you need this rule to execute in response to another rule." box checked.

![Rule to update the Epic work log from a Story update.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/323952iA1409EFF73400995/image-size/large?v=v2&px=999 "Rule to update the Epic work log from a Story update.jpg")![Rule to update the Story work log from a sub-task update.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/323953iCFAD202C8342A84D/image-size/large?v=v2&px=999 "Rule to update the Story work log from a sub-task update.jpg")


author: Bobby Williams
body: [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306) [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)

Sorry for the delay, but I found out that my automation wasn't working for summing up the total logged work into the Epic. I am using the flows from several articles in the community, but it doesn't work when work is added to a sub-task which adds to the story, but not the Epic.

If I manually add time to the Story, the epic is updated. My calculations above are not even being considered by automation.

I am now back to troubleshooting the automation to update the Epic with time logged on a sub-task of a story.

![Audit log showing that a story triggers the rule, but not a sub-task of the story.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/323883i8CACAA2BAB70E522/image-size/large?v=v2&px=999 "Audit log showing that a story triggers the rule, but not a sub-task of the story.jpg")![Automation flow diagram.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/323882iC2AA34A63589AFE8/image-size/large?v=v2&px=999 "Automation flow diagram.jpg")

comments: author: Kalyan Sattaluri
body: Hello [@Bobby Williams](/t5/user/viewprofilepage/user-id/5496098)

Usually, this is a symptom of you not referencing correct field.

What I mean is, in your Jira set up, you have 2 or more fields of the same name "worklog".

You need to find the customfield value and use that name to update, instead of {{worklog.timespent}}.

So to trouble shoot and find the correct customfield value:

* Log into your Jira, find Issue key where you have manually entered this time spent. (say its ABC-123)
* Open new browser Tab in same session, and put in below URL, replacing bolded parts
* https://**yourdomain** .net/rest/api/2/issue/**ABC-123**?expand=names
* Once you see response, inspect the JSON and find the customfield name which holds the value you have entered for the issue.
* Then use that field to update your epic in your automation. It should be of the format customfield_xxxx, so you will use {{customfield_xxxx.timeSpent}}.

Hope it helps.


author: Bill Sheboy
body: As written, I would not expect that rule to update a Story when work is logged for a Subtask. The reason is the branch is to Epic (parent), and Subtasks do not have an Epic for a parent.


author: Kalyan Sattaluri
body: \^\^. Thanks Bill.

[@Bobby Williams](/t5/user/viewprofilepage/user-id/5496098) - Please clearly state what are you trying to do and what is working.

I thought your sub-tasks -\> story update was working and story-\>Epic is not.

But now that I reread your post, I am confused if thats even the case.

So please clearly state what is working and what next are you are trying to do before going to deep.

Also, This topic has been covered pretty well in the forums. If you are referencing a particular post, share that link as well.


author: Bobby Williams
body: As shown in the rule diagram above, if I manually add work log time to a story, the Epic work log gets updated.

However, if I add time to a sub-task, the story gets updated (include child issues is checked), but the Epic doesn't get updated.

It would seem that if the Story worklog get updated, either manually or cumulatively, then the Epic would update its worklog.

Manually adding time to the Story will update the Epic worklog.


author: Bill Sheboy
body: Hi [@Bobby Williams](/t5/user/viewprofilepage/user-id/5496098) -- Welcome to the Atlassian Community!

For a question like this, please post an image of your complete automation rule, images of any relevant actions / conditions / branches, an image of the audit log details showing the rule execution, and explain what is not working as expected. Those will provide context for the community to offer ideas. Thanks!

Until we see those...

Some of those smart values you are using are the output-formatted ones for time tracking and not numbers. For example, I believe the one to use for original estimate in a math expression is this:

```
{{issue.timetracking.originalEstimateSeconds}}
```

Please confirm the smart values you are using are numbers.

Kind regards,  
Bill

comments: author: Bobby Williams
body: I apologize for the lack of documents and screenshots.

I am a newbie in this forum, but should know better :(

I will do better.


author: Kalyan Sattaluri
body: Hello [@Bobby Williams](/t5/user/viewprofilepage/user-id/5496098)

Your syntax as you have listed is fine but why isnt it resolving to a value?

We dont know.

You havent shared your rule screenshot or audit log.

Please log all these smart values outside/before the calculation step, run the rule and share the rule/audit log so community can help.


Tags: cloud

jira

jira-cloud