Forums

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

escalation service to auto close jira tickets

Mary Mark May 7, 2020

Hi

I'm looking to create an escalation service that will set resolved jira tickets to "Close" status when they have been resolved for more than 7 days

However, on the "close" transition there is a required field called: Performance Feedback to prompt the user to enter a value

I would like to set this to a default value of: Met Expectations without manually setting it.

 

Below is the code. What is not working is setting the Performance fieldback field value to:

Met expectations.

 

In the escalation service:

I left the following unchecked:

 

skip permission

skip validator

skip condition

 

If i checked all of them, the performance feedback value is blank...

-------------------------------------------------------------------------

 

 

def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Performance Feedback'}
issueInputParameters.addCustomFieldValue(cf.name, 'Met Expectations')

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.comments.CommentManager

CommentManager commentManager = ComponentAccessor.getCommentManager()

commentManager.create(issue, currentUser, 'This ticket has been in "Resolved" state for 7 or more days without an update. This ticket will be automatically moved to "Closed" state.', true)

 

 

-----------------------------------------------------------------------

 

Any help is appreciated.

 

Thanks,

Mary

1 answer

0 votes
Kian Stack Mumo Systems
Community Champion
May 7, 2020

Mary,

I just based mine on the template Scriptrunner provides.  Please try something like this.

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.comments.CommentManager

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObjectByName("Performance Feedback") // name of CF

def optionsManager = ComponentAccessor.getOptionsManager()

def fieldConfig = customField.getRelevantConfig(issue)
def option = optionsManager.getOptions(fieldConfig).find { it.value == "Met Expectations" } // value of option

issueInputParameters.addCustomFieldValue(customField.id, option.optionId as String)
issueInputParameters.setSkipScreenCheck(true)

CommentManager commentManager = ComponentAccessor.getCommentManager()

commentManager.create(issue, currentUser, 'This ticket has been in "Resolved" state for 7 or more days without an update. This ticket will be automatically moved to "Closed" state.', true)

 
Mary Mark May 7, 2020

Hi Kian,

This works!

Do i have to call this explicitly?

 

issueInputParameters.addCustomFieldValue(customField.id, option.optionId as String)
issueInputParameters.setSkipScreenCheck(true)

 I already uncheck the boxes.. to not allow skip transition/condition/validator.

 

Thanks,
Mary

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events