Forums

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

In automation, how do I change the "due date" field based on a change in another custom date field?

Scott Pelton-Stroud
Contributor
March 2, 2022

I have an issue with custom field "Start date", and I would like to edit the "due date" field of the same issue based on changes to this Start date. Specifically, if the "Start date" is increased by one week, then I would like the "due date" (which is distinct) to also increase by one week.

I have been trying to create an automation for this, but it seems my smart values are non-functioning. I am using the following set up:

Trigger: When value changes for "Start date"

Condition: key = HR-4044 (to isolate testing to one issue)

Action: Then edit issue field "Due date" to: {{issue.duedate.plusDays(fieldChange.from.diff(fieldChange.to).days)}}

 

The above automation results in no errors but an empty "due date" field... The above underlined smart value seems to be the issue. I have confirmed using a strict number in the smart value works fine (ie {{issue.duedate.plusDays(30)}} ), and I tested some smart values in the description to learn more.

The following smart values in the description...

1. {{fieldChange.from.diff(fieldChange.to).days}}

2. {{now.diff(fieldChange.to).days}}

3. {{fieldChange.from.diff(now).days}}

4. {{now.diff(issue.created).days}}

5. {{fieldChange.from}}

6. {{fieldChange.toString}}

7. {{now.diff(xx).days}}

...create the following result:

1.

2.

3.

4. 0

5. 2022-03-10

6. 17/Mar/22

7. 

So it seems fieldChange.from and fieldChange.to are not being recognized as dates in the smart value scheme {{[date1].diff([date2]).[unit]}}, which I learned from this article.

The field that's being changed, "Start date", is a custom Date Picker field.

...Any advice? If there is no solution via this method I'm trying, is there another method available?

1 answer

1 accepted

3 votes
Answer accepted
Stefan Salzl
Community Champion
March 3, 2022

Hi @Scott Pelton-Stroud ,

As far as it seems to me the {{fieldChange}} output is not a date and therefore no calculation can be done.

I just manipulated the script of your first attempt to the following:

{{fieldChange.from.toDate.diff(fieldChange.to.toDate).days}}

 

Converting toDate before the diff worked on my site. Please try out. Would be happy to see it working 😉

Best
Stefan

Scott Pelton-Stroud
Contributor
March 4, 2022

That worked! Thank you very much Stefan :)

Like Stefan Salzl likes this
Stefan Salzl
Community Champion
March 4, 2022

You are welcome 😉🙌🏼

Would you please accept the answer? This marks the question as answered and makes it easier for other users with similar problems to find a solution 😉

Best
Stefan

Like Scott Pelton-Stroud likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events