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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.