Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How can I change a date based on input from non-date fields using Jira Automation?

I am trying to create an automation that will clone an issue and update the due date to a specific date depending on input from two custom fields.

For example, the user may choose to clone the task monthly on the 3rd of the month.
They may also choose to clone the task annually on the 15th of the month.

I have one custom field for choosing the frequency of the clone.
I have a second custom field for choosing which day of the month the task should be due.

Both custom fields are single choice select lists.

 

If I use the smart value {{issue.Due Day.value}}, I get the chosen result which is an integer between 1 and 30.

How do I use that value to drive another smart value?

For example if I type {{issue.created.withDayOfMonth(1)}} into the value for Due date, it will change to the first of the current month.

But {{issue.created.withDayOfMonth(Due Day)}} does nothing.
I've tried formatting it a few ways, but think I must be going down the wrong path.

Perhaps I can append values in the Additional fields section?

1 answer

1 accepted

2 votes
Answer accepted

Hi @Brock Jolet -- Welcome to the Atlassian Community!

First thing: there is a built-in field called Due Date, so I recommend using another name.  The built-in field is what drives time ranges for things like roadmaps.

Next, in your calculation ensure you fully specify the field smart value, such as:

{{issue.created.withDayofMonth(issue.myDueDateCustomFieldName)}}

One thing to help as you work through this is to use the log action to write pieces of the value to the audit log...and as you add pieces you can more easily see the impact.

If this still isn't working, please consider posting an image of your entire rule and an entry from the audit log showing an execution.  That will provide context for the community to offer ideas.

Best regards,
Bill

Hello @Bill Sheboy , thanks for the reply.

Here is a collection of screenshots to demonstrate what I am seeing.
First I convert the custom field value to a temporary value that displays correctly in the audit log as "1".

Due Day: 1

The issue had a starting value in the Due Date field of 2021-06-01.

When this rule runs, the value should not change since the card was created in June and the Due Day is 1.

However, it appears the smart value {{issue.created.withDayOfMonth(issue.dayChosen)}} is not valid, so the Due Date field simply becomes empty.

In the second audit log I also included the results of manually assigning the value of 1.

 

2021-07-09_14-04-30.jpg

Ah, now I see...Created Variables cannot be used a parameters in smart value functions (yet...)

Have you tried to directly use that field value in the expression:

{{issue.created.withDayOfMonth(issue.Due Day.value)}}

Like Brock Jolet likes this

@Bill Sheboy Yep. I get the same result. There is no error, but the field is left empty.

If you write that to the audit log rather than try to change the field, does it work?

If not, please try without the .value expression:

{{issue.created.withDayOfMonth(issue.Due Day)}}

And, would you please confirm if the Due Day custom field type is Numeric in the setup?  Thanks!

Like Brock Jolet likes this

@Bill Sheboy Even when written to the audit log I get an empty value whether I use .value or not.

Due Day is a Select List (single choice) with a series of numeric choices.

2021-07-12_10-41-32.jpg

Thanks for that info, and... Your field looks like a number, but it is not one because it is in the list field.  Let's try to convert it into a number before doing math on it:

{{issue.created.withDayOfMonth(issue.Due Day.asNumber)}}

Like Brock Jolet likes this

@Bill Sheboy Thanks! That got me to where I needed to be.

Just using .asNumber wasn't enough, but using .value.asNumber worked.

 

{{issue.created.withDayOfMonth(issue.Due Day.value.asNumber)}}

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
Community showcase
Published in Jira

⏰ Day in the life of a Jira Admin!

Hello Community! We thoroughly enjoyed this just-for-fun conversation in the Jira Admin Group about what it's like to be a Jira Admin. For #JiraJuly, our talented designers created these graphics t...

47 views 0 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you