Hello Community,
I am trying to figure out how I can add a comment if the Status of an Issue changes
I would like to add a functionality such that when a certain event occurs, the status of an issue should automatically changed from "Open" to "In progress" if a comment will be added as example
I know it is not finished but I tried accomplishing this with the following code
if(issue.getIssueType().name=="Task"){
MutableIssue epic = issue
epic.setStatusId("2"); //Read that 2 meant status = "Done"
}
Could someone provide me with guidance regarding this issue.
I appreciate all the help!
Regrads cennet
Hi,
I'm a bit confused.
Do you want a transition to occur if a comment is added?
Or do you want a comment to be added if a transition occurs?
I'm assuming the first.
We have implemented this with a Script Listener.
Create a Script Listener, select the project(s) to which it applies and select 'Issue Commented' as Event.
Then the script goes:
// Imports
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.IssueInputParametersImpl;
import com.atlassian.jira.issue.Issue;
// Variables
Issue issue = event.issue;
def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser();
def transitionId = 33; // the transion id you need to have triggered
def issueService = ComponentAccessor.getIssueService();
def issueInputParameters = new IssueInputParametersImpl();
def transitionValidationResult = issueService.validateTransition(user, issue.id, transitionId, issueInputParameters);
// Function
if (transitionValidationResult.isValid()) {
issueService.transition(user, transitionValidationResult);
}
In our implementation we added an if statement in front of the function that filters out certain users and makes sure the issue is in a specific status to start with.
Hi @sue molly
Status is a not a field that you can set. You need to transition the issue. I wrote a script to transition the issue with some instructions. Take a look.
Adding a comment is an event which you can capture and do something like transitioning an issue (changing status). You can listen to these events by creating a Script Listener.
So create a listener using "Issue Commented" event and write a custom script to transition the issue.
I hope it helps.
Ravi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Earning the Mindful Member badge proves you know how to lead with kindness, plus it enters you into a giveaway for exclusive Atlassian swag. Take the quiz, grab the badge, and comment on our announcement article to spread the good vibes!
Start here
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.