import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
Issue issue = issuedef customFieldManager = ComponentAccessor.getCustomFieldManager()
// the dependent custom field
def dateACF = customFieldManager.getCustomFieldObjectByName("Due Date")
// get the value of the Due Date custom field
def dateAValue = issue.getCustomFieldValue(dateACF) as Date
// build the new date
def dateB = Calendar.getInstance()
// copy to the new date the value of the Due Date custom field
dateB.setTime(dateAValue)
return dateB.getTime()
When I run this , I get an error as "java.lang.NullPointerException"
Can someone please help me out. Thanks
You should add logging to your script and see in the logs, what object gives you a NullPointerException. It could be done like this
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
Issue issue = issuedef customFieldManager = ComponentAccessor.getCustomFieldManager()
// the dependent custom field
def dateACF = customFieldManager.getCustomFieldObjectByName("Due Date")
log.error("dateACF: " + dateACF)
// get the value of the Due Date custom field
def dateAValue = issue.getCustomFieldValue(dateACF) as Date
// build the new date
def dateB = Calendar.getInstance()
// copy to the new date the value of the Due Date custom field
dateB.setTime(dateAValue)
return dateB.getTime()
@Alexey Matveev Thank you for your reply Alexey. I tried your script above and got the below error,
groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.issuedef() is applicable for argument types: (com.atlassian.jira.issue.managers.CachingCustomFieldManager) values: [com.atlassian.jira.issue.managers.CachingCustomFieldManager@52e105aa]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It is strange error. I can not see a reason why it would be caused by the code. Could you try again?
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.
Yes, I got it. Try like this:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
// the dependent custom field
def dateACF = customFieldManager.getCustomFieldObjectByName("Due Date")
log.error("dateACF: " + dateACF)
// get the value of the Due Date custom field
def dateAValue = issue.getCustomFieldValue(dateACF) as Date
// build the new date
def dateB = Calendar.getInstance()
// copy to the new date the value of the Due Date custom field
dateB.setTime(dateAValue)
return dateB.getTime()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
And the correct script would be like this:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
// get the value of the Due Date custom field
def dateAValue = issue.getDueDate() as Date
// build the new date
def dateB = Calendar.getInstance()
// copy to the new date the value of the Due Date custom field
dateB.setTime(dateAValue)
return dateB.getTime()
The problem is that Due Date is not a custom field and you should get the value of the field by issue.getDueDate()
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.
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.