Hi,
To add the value of a number customfield to a date field in a Set Issue Fileds Post Function I'm trying on this way as Groovy script:
new Date() + issue.get("customfield_21011") + 7
It didn't works. Any ideas?Thanks, Martin
Hi @Martin Heini
I'm not sure I understand what you're trying to achieve. Is customfield_21011 your number field? And are you trying to set a Date field to "now" + a number of days equal to the value of customfield_21011 + 7 days?
When you say it doesn't work, what does it do exactly? Are you getting any errors? Are you getting a wrong date?
try smart values? {{issue.customfield_21011}}
https://appfire.atlassian.net/wiki/spaces/JMWEC/pages/466322168/Tags+and+Expressions
Hi DavidYes, this is exactely what I want to do.
Target is a customfield of type date,customfield_21011 is of type number,7 is a constant
Then the problem is that the value of your Number field is a Double (floating point), not an Integer, and Groovy doesn't know how to add floating point numbers to a Date.
Also, you need to add code to manage the case where customfield_21011 is empty.
This code will consider an empty customfield_21011 field as 0:
new Date() + (int)(issue.get("customfield_21011") ?: 0) + 7
Hi David
Yes, that's the solution I was looking for. Thank so much.
Martin
Hi Dick
I tried {{...}} without succsess. As I understand setContextVar, it is a variable set in a certain context. Here I was looking for a variable that the user can set freely via a screen.Thanks anyway.
It looks like you're new here. Sign in or register to get started.