Automate Log Work from Issue Transition Trigger Not Working
Asked by Jessica Rubeo:

Hi all! I'm working on an automation for auto work time logging that uses three separate fields in JIRA; two custom (listed below) and one native (Work Log).

The two custom date/time picker fields are "In Progress Start Time" and "Done Time". I have two separate automations that are triggered by the "Issue Transition" trigger that prints the {{now}} variable to the "In Progress Start Time"/"Done Time" fields when an issue is transitioned into "In Progress"/"Done". These two automations are functioning as expected and the date/time is being printed properly.

My third automation is also being triggered by an "Issue Transition" from any status into the "Done" statuses:

![autoLogWork.PNG](/t5/image/serverpage/image-id/338966iD28D7773E5F89052/image-size/large?v=v2&px=999 "autoLogWork.PNG")

I added a delay because I often get this error readout:

![autoLogWork2.PNG](/t5/image/serverpage/image-id/338967i2752E282B4D86924/image-size/large?v=v2&px=999 "autoLogWork2.PNG")

And I figured it was because the automation is running too quickly and the "Done Time" timestamp automation doesn't have enough time to register before the Work Log one runs, but this hasn't seemed to fix anything. I know the work log action works properly because if I then change the issue status from "Done" to "Canceled", for example, it accurately logs the time between the "In Progress Start" and the "Done Time" date/time picker fields.

It seems as though the automation is running too quickly for the Work Log action to function correctly, but I've reorganized and tried adding delays and whatnot; nothing seems to be working.

Any help would be very much appreciated!


Answers:
author: Trudy Claspill
body: Hello [@Jessica Rubeo](/t5/user/viewprofilepage/user-id/5556833)

Welcome to the Atlassian community.

I believe the problem is in the smart value you have used in your Log Work step. Can you provide a screen image that shows all the details of that step, please?

Also, try adding the Log Action to write into rule execution audit log the exact smart value you are trying to use in the Log Work action.

comments: author: Bill Sheboy
body: Hi [@Jessica Rubeo](/t5/user/viewprofilepage/user-id/5556833) -- Welcome to the Atlassian Community!

~~Adding to Trudy's suggestions:~~

~~There is a typo in your write to the audit log: it is missing the closing parenthesis for the call to the diff() function. That is why it shows the "Error rendering smart-values..."~~

*Update: striking through this suggestion.*

Kind regards,  
Bill


author: Trudy Claspill
body: Was that Log action there all along? Too much multi-tasking again.

The image I see currently in the original post doesn't have a typo, does it?

![Screenshot 2024-07-30 at 2.38.08?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/338985i26F9D2D00EE0580E/image-size/large?v=v2&px=999 "Screenshot 2024-07-30 at 2.38.08?PM.png")


author: Bill Sheboy
body: Oops...my mistake; thanks, Trudy!

We cannot see the write to the log in what was posted. Seeing what was written with the write to the audit log may explain why the Log Work action is failing. (Although I suspect removing the math function wrapper will help.)


author: Trudy Claspill
body: [@Jessica Rubeo](/t5/user/viewprofilepage/user-id/5556833)

Can you also add Log actions to print out the two custom fields that you are referencing in the smart value you are using in the Log work action?

issue.customfield_10109 and issue.customfield_10110

[@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) I tried using the math function wrapper myself, but using now() instead of referencing custom fields, and the Automation rule did not object.

![Screenshot 2024-07-30 at 3.33.06?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/338991i67A61A5B3AC4EBB1/image-size/large?v=v2&px=999 "Screenshot 2024-07-30 at 3.33.06?PM.png")

![Screenshot 2024-07-30 at 3.33.21?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/338990i8D26D41C4FFE5F16/image-size/large?v=v2&px=999 "Screenshot 2024-07-30 at 3.33.21?PM.png")


author: Valerie Knapp
body: Hi [@Trudy Claspill](/t5/user/viewprofilepage/user-id/3569011) , [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) , I understood part of the point / problem here is trying to obtain the sum / difference between the two custom fields of date time. I am also struggling with this.

I have got to here -

```
{{#=}}{{issue.customfield_10009.minus(issue.customfield_10008)}}{{/}}m
```

Where 9 is a change completion date time

and 8 is the change start date time

But I don't get the automation to take the action of logging the work, even though I can get it to calculate the difference between these two fields.

Do you have any advice about how to get this to work please?

Cheers


author: Bill Sheboy
body: Greetings, everyone!

Let's pause and try some basic diagnostics to help...

[@Jessica Rubeo](/t5/user/viewprofilepage/user-id/5556833) , in your rule please add a write to the audit log with these expressions, and then run it, posting the audit log details from the execution:

```
customfield_10109 equals: {{issue.customfield_10109}}

customfield_10110 equals: {{issue.customfield_10110}}

diff of values: {{issue.customfield_10109.diff(issue.customfield_10110).minutes}}
```

This will confirm the fields have non-null values and that Jira correctly interprets them as date / time values. Otherwise the diff() result will be null.

============================

Hi, [@Valerie Knapp](/t5/user/viewprofilepage/user-id/4929946)

The math functions plus() and minus() should work with date and date / time values, as they are probably implemented as numbers (i.e., milliseconds since 1 January 1970). However, I have observed inconsistent results in some contexts and so please try using the date and date / time, diff() function with the units of measure needed.

Thanks!


author: Jessica Rubeo
body: Thanks everyone for your feedback! [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) , I've inputted the Audit Log actions as you've outlined, reflected in the screenshots below:  
![autoLogWork4.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/339166iE303776E945E5456/image-size/large?v=v2&px=999 "autoLogWork4.PNG")

However it seems as though I'm still getting the "Empty Expression" error:  

![autoLogWork5.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/339167i20F418F42B5D896E/image-size/large?v=v2&px=999 "autoLogWork5.PNG")

Is there a specific way I need to nest these actions for it to reflect correctly in the Log work section?


author: Bill Sheboy
body: Yes, I expected that to still fail...and, you are only showing part of the audit log entry for the rule execution.

Please show the *entire log entry's details*. That will show the writes to the log to confirm the smart values which were just added.


author: Jessica Rubeo
body: Apologies for the delay, attached please find the correct readout.![autoLogWork6.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/339437i5B916DF6D5ED64BE/image-size/large?v=v2&px=999 "autoLogWork6.PNG")


author: Trudy Claspill
body: The last Log action is missing the second curly brace at the end, which is why the last log action shows an error.

Please correct that, run the rule again, and post the new log output.

![Screenshot 2024-08-01 at 7.57.02?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/339475i4C7190A8E078668E/image-size/large?v=v2&px=999 "Screenshot 2024-08-01 at 7.57.02?AM.png")


author: Bill Sheboy
body: Apologies again...my original post had two typos: curly bracket instead of close parenthesis and missing curly bracket at end.

Here is the corrected one:

```
diff of values: {{issue.customfield_10109.diff(issue.customfield_10110).minutes}}
```


author: Valerie Knapp
body: Hey [@Jessica Rubeo](/t5/user/viewprofilepage/user-id/5556833) , did this get resolved for you or do you still need more input?


author: Valerie Knapp
body: Hi [@Jessica Rubeo](/t5/user/viewprofilepage/user-id/5556833) , welcome to the Atlassian Community and thanks for your question.

You could try this action instead of the delay -

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/338971i19C48B45783F262E/image-size/large?v=v2&px=999 "image.png")

which should get the latest status and transition info.

Please give it a go and share your feedback.

Good luck!

comments: author: Jessica Rubeo
body: Hi [@Valerie Knapp](/t5/user/viewprofilepage/user-id/4929946) ! Thank you for your warm welcome and quick reply :)

That definitely feels like a closer step, however I've still gotten the same "empty expression" error:

![autoLogWork3.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/338972i58D3C440B853EE98/image-size/large?v=v2&px=999 "autoLogWork3.PNG")


Tags: automation

cloud

jira-cloud

worklog