Forums

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

How update priority for subtask

Ruslan February 27, 2023

Hi,guys. 

 

I have listener : issue created. 

I need copy field priority and flagged, when subtask create.

I started with priority,but this code dont work without exeptions:

 

if(!issue.isSubTask()){
      return
}
else{
 def parentIssue = issue.parentObject
 log.warn parentIssue.getPriority().getId()
issue.setPriorityId(parentIssue.getPriority().getId())
}
Field is not update.
pls help

1 answer

0 votes
Ruslan February 27, 2023

Im trying else

 

def parentIssue = issue.parentObject
String priorityName = parentIssue.getPriority().name

def issueService = ComponentAccessor.issueService
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def availablePriorities = ComponentAccessor.constantsManager.priorities
def highPriority = availablePriorities.find { it.name == priorityName }

def issueInputParams = issueService.newIssueInputParameters()
issueInputParams.with {
    priorityId = highPriority.id
}

def updateValidationResult = issueService.validateUpdate(loggedInUser, issue?.id, issueInputParams)
def updateResult = issueService.update(loggedInUser, updateValidationResult, EventDispatchOption.ISSUE_UPDATED, false)
but have error issuetype=Issue type is a sub-task but parent issue key or id not specified.

Suggest an answer

Log in or Sign up to answer