Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

prevent subtask creation/issue creation.

140401 kindia
May 18, 2017

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 !

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
June 25, 2022

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



TAGS
AUG Leaders

Atlassian Community Events