Hi,
I am using this script below:
// required import statements
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserUtil
import java.util.Date.*
import com.atlassian.jira.issue.CustomFieldManager
CustomFieldManager customfieldmanager = ComponentAccessor.getCustomFieldManager()
def BOMdate_field = customfieldmanager.getCustomFieldObject('customfield_14403')
def BOMdate_val=issue.getCustomFieldValue(BOMdate_field) as Date
BOMdate_val.after(Calendar.getInstance().getTime())
The issue is that when i picked current date and I am getting error message.
Please advice.
Thanks,
Swarna
i guess this is a way to work around today's date (replace your last row):
def startOfToday = Calendar.getInstance()
startOfToday.set(Calendar.MILLISECOND, 0)
startOfToday.set(Calendar.SECOND, 0)
startOfToday.set(Calendar.MINUTE, 0)
startOfToday.set(Calendar.HOUR_OF_DAY, 0)
!BOMdate_val.before(startOfToday.getTime())
Hi IIya,
Thanks a lot,
It is now working :)
Thanks,
Swarna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
if the customfield has no value in it BOMdate_val will be null and you won't be able to invoke the .after method on it
you can avoid it by safe navigation:
BOMdate_val?.after(Calendar.getInstance().getTime())
in this case if BOMdate_val is null, whole construction will return null (which is considered false in this case)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi IIya,
It is the same. Error message is being displayed. Please see screenshot.
Thanks
Swarna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
well, it just means that the validator you created works correctly. it doesn't allow you to select the date that is greater than NOW. and your field type is Date, so it's stored as 00:00 of a day you selected, while Calendar.getInstance().getTime() is also current time, which is always later than the start of day.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Swarna Radha ,
Would you mind showing the full stack trace of the error so we can troubleshoot further.
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.