Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira Automation - Dinamically set a date in Log Work action

Nicola Zerbini
February 11, 2025

I'm trying to create an automation that logs work on multiple days, based on user inputs on trigger.

I tried tons of different approaches to set the date, generally creating a list of selected days and branching on each element of the array. At the moment, the array can contain strings like MON, TUE, WED, THU and FRI and use them inside the withNextDayOfWeek attribute. I already debugged the array branching output and its correct, each value is correctly taken.

Can someone please help me? I've been on this automation for days now and I can't understand what I'm doing wrong. 

 

Screenshot 2025-02-11 104650.pngScreenshot 2025-02-11 104747.png

1 answer

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 Champions.
February 11, 2025

Hi @Nicola Zerbini -- Welcome to the Atlassian Community!

What problem are you trying to solve with this rule?  That is, "why do this?"  Knowing that will help the community provide better suggestions.

Until we know that...

Please post images of:

  • the audit log details showing the rule execution
  • the Manual Trigger's complete set of inputs
  • the Create Variable for weekDays
  • the Advanced Branch

And please explain what is not working as you expected, and why you believe that to be the case.

Kind regards,
Bill

Nicola Zerbini
February 11, 2025

@Bill Sheboy thank you for your answer! As I said in my question the automation is meant to allow people to log the same amount of time on multiple days of the week with few clicks, since part of the team is following a fulltime task for a while.

Starting from the manual trigger, they must insert:

  • hours and minutes they want to log on all the days (2 numbers)
  • if they want to log on current or last week (Dropdown)
  • which week days they want to log for (5 checkboxes)

Since the automation block is too big to make a screenshot, I post here a screenshot of the final interface in the manual trigger

Screenshot 2025-02-11 173858.png


For weekDays creation, the smart value field is quite long, so I'll post here the formula:

{{if(userInputs.monday, "MON", "")}}, {{if(userInputs.tuesday, "TUE", "")}}, {{if(userInputs.wednesday, "WED", "")}}, {{if(userInputs.thursday, "THU", "")}}, {{if(userInputs.friday, "FRI", "")}}

Here's how I branch on this list:

Screenshot 2025-02-11 172913.png

As I said, I already debugged this part and it's working properly (Sorry my debug is in italian, they are 5 different audit log). The first value is missing because I didn't check Wednesday box.

Screenshot 2025-02-11 173048.png


For the execution audit log, here the error. I debugged all the values I'm using inside the Log Work action. The log is the following:
Screenshot 2025-02-11 173314.png


I hope these informations will be helpful to better understand my 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 Champions.
February 11, 2025

Thanks for the additional information.

Did you notice when you create the variable, the delimiter between the values is a comma-followed-by-a-space, but in the Advanced Branch, the split() function only uses a comma?

This will result in a leading space for some of the values...and potentially an empty value when only MON-THU are selected (due to the trailing comma).

 

Please try changing the variable create to always delimit with commas (moving them inside of the true clauses for each day, including Friday:

{{if(userInputs.monday, "MON,", "")}}{{if(userInputs.tuesday, "TUE,", "")}}{{if(userInputs.wednesday, "WED,", "")}}{{if(userInputs.thursday, "THU,", "")}}{{if(userInputs.friday, "FRI,", "")}}

And then change the Advanced Branch to remove the last comma before the split():

{{weekDays.substringBeforeLast(",").split(",")}}

 

One last thing: ensure in your Manual Trigger that the checkbox field variable names exactly match the smart values in your conditions, including the case.  Otherwise they will return null.

Nicola Zerbini
February 12, 2025

Thanks for your advices, unfortunately the automation still doesn't work. I replaced my formulas with yours and checked the manual trigger checkboxes smart values (they were correct).

I tried to debug the weekDay right inside the branching and the output is correct, but still the formula inside the Log Work action is not working. I leave a screenshot of the new structure of the branch and of the latest audit log error.

 

Thank you very much for your help!

Screenshot 2025-02-12 104826.pngScreenshot 2025-02-12 104730.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 Champions.
February 12, 2025

Please add a write to the audit log with the exact expression you are trying to use in the Work Log time action, run the rule, and post updated images of the rule and audit log.

That will confirm if your expression is generating a valid date.

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 Champions.
February 12, 2025

Oh, I see it now: there is no function startOfWeek. 

Please use a different method for that first day, such as the with... functions: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/#Date-with-attribute---

 

Suggest an answer

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

Atlassian Community Events