Hi Team,
i need help for few of my questions and if its possible then how to implement them .
In JIRA workflow for my client ,i have created grrovy script that creates subtask when parent issue is created but now i wanted to add some constraints when a manual subtask is being created for a parent issue.
1. if autocreated subtask exists with same summary then manually new subtask should not be created.
2. if my parent issue is makred to done then also it should not allow to create a new subtask manually.
3. parent issue is marked to done, once all subtasks are done then subtasks should not be allowd to move into other status even if transition from done to inprogress does exist.
Kinldy provide some code or scripts that can help me achiving above mentioned points.
Thanks in advance !
It would help to know the type of each of those custom fields and see more concrete examples.
Also, does ProjectA-Key contain a project key? Or does it contain an issue key that happens to belong to Project A?
But something like this should put you on the right track:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
def issueService = ComponentAccessor.issueService
def issue = event.issue as Issue
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def projectAKeyCf = ComponentAccessor.customFieldManager.getCustomFieldObjectsByName('ProjectA-Key')[0]
def changeRequestCf = ComponentAccessor.customFieldManager.getCustomFieldObjectsByName('Change Request')[0]
def projectAKey = issue.getCustomFieldValue(projectAKeyCf)
def changeRequest = issue.getCustomFieldValue(changeRequestCf)
def projectAIssue = ComponentAccessor.issueManager.getIssueObject(projectAKey as String)
def iip = issueService.newIssueInputParameters()
iip.addCustomFieldValue(changeRequestCf.id, changeRequest as String)
def validationResult = issueService.validateUpdate(currentUser, projectAIssue.id, iip)
assert validationResult.valid, validationResult.errorCollection
def updateResult = issueService.update(currentUser, validationResult)
assert updateResult.valid, updateResult.errorCollection
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.