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
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?
Hi David
Yes, 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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David
Yes, that's the solution I was looking for. Thank so much.
Martin
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
Martin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.