Hello,
I am trying to set up a custom listener on issue creation that checks if the original and remaining estimates are empty, and in that case, set both to "1m".
I tried some solutions that I found in the community but I did not manage to get them working as expected.
Can anyone help me? What methods should I use to get and set both values?
Thank you in advance!
Hi Reno,
The below code should work for your need.
Please also consider this answer as accepted if this is the solution you were looking for. That will make it more traceable for users in the future if they are facing the same issue.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import org.apache.log4j.Category
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.bc.issue.IssueService
def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction")
log.setLevel(org.apache.log4j.Level.DEBUG)
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
IssueManager im = ComponentAccessor.getIssueManager()
def issue = issue
//def issue = im.getIssueObject("ABR-39")
IssueService issueService = ComponentAccessor.getIssueService()
if (!issue.getEstimate() && !issue.getOriginalEstimate()){
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.setOriginalAndRemainingEstimate('1m','1m')
def updateValidationResult = issueService.validateUpdate(loggedInUser, issue.id, issueInputParameters)
if (updateValidationResult.isValid()) {
// Validate the update
def issueResult = issueService.update(loggedInUser, updateValidationResult)
}
}
//log.info(issue.getEstimate())
//log.info(issue.getOriginalEstimate())
//log.info(issue.getTimeSpent())
Thanks,
Aditya
Thank you so much Aditya, it works as expected!
This is also very helpful to get me started with other scripts, since I am still struggling with the Jira API.
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.