I have a custom field which allows selecting versions. From the selected version in the field, the release date should be extracted and that should be set as the due date for an issue created . (say newSubTask ). How to do that?
What I did was:
def versionCF = customFieldManager.getCustomFieldObjectByName("Fix Version(s)")
String valueOfversionType = parentIssue.getCustomFieldValue(versionCF)
Project project = parentIssue.getProjectObject()
Version versionn = versionManager.getVersion(project.getId(), valueOfversionType)
newSubTask.setDueDate(new Timestamp(versionn.releaseDate.time))
But I get the following error:
2016-11-23 10:18:10,909 ERROR [workflow.ScriptWorkflowFunction]: ************************************************************************************* 2016-11-23 10:18:10,911 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: TPK-129, actionId: 1, file: <inline script> java.lang.NullPointerException: Cannot invoke method getReleaseDate() on null object at Script1007.run(Script1007.groovy:61)
Dear @Shagufta Gurmukhdas, Fix versions is not a custom field. It is a build-in field. To get it you should use
issue.getFixVersions()
it returns a collection of all Fix Versions.
No, Fix Version/s is the built-in field, but i have created a custom field named Fix Version(s) since I had to make it mandatory in my project and making mandatory the built in field would have made it mandatory for all projects that use it.
So, basically, my field IS a custom field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Vasiliy Zverev can you help with that? with doing it through a custom field?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Namely trouble is that versionn is null. It means that
versionManager.getVersion return null
Here is modified code
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.project.version.Version Issue parentIssue = null CustomField versionCF = customFieldManager.getCustomFieldObjectByName("Fix Version(s)") Version versionn = versionManager.getVersion( parentIssue.getParentObject().getProjectId() , parentIssue.getCustomFieldValue(versionCF)) if(versionn == null) return newSubTask.setDueDate(new Timestamp(versionn.getReleaseDate().getTime()))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, I have written versionn.getReleaseDate().time, not versionn.releaseDate.time . But anyway, both aren't working
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.