Hi!
I need to automatically transition an issue to another status when a datetime custom field reaches current time. How could I implement this using Adaptavist ScriptRunner plugin?
Hi , you can try Listeners.
You might find https://library.adaptavist.com/search?q=transition helpful when looking to write scripts for transitions on issues.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
But Listeners require a special event to occur to act. I dont have any events going on, the issue might not change at all. I want it to transition when the time's right. Is this possible when using Listeners?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, listeners need an event.
But you could easily write a service that regularly runs a filter such as "due date is today" or "updated over a week ago" and transitions any issues it finds (Obviously, I'd recommend much more careful filters than I've just suggested)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is why I wanted to use service over listener. This is literally in my original question. Can I get more help on services?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here's my code.
Also how do I get multiple issues to use this with JQL?
// INF 31.07.2019
// source: https://community.atlassian.com/t5/Answers-Developer-Questions/Proper-way-to-change-issue-status-in-code/qaq-p/535798
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue;
import java.util.Date;
import java.util.ArrayList;
import java.util.stream.Collectors;
import com.atlassian.jira.workflow.WorkflowTransitionUtil;
/* The object facade class */
Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade");
MutableIssue issue1 = getIssueObject();
/* The reference to the object facade which you can use in your code */
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass);
def deadLine = issue1.get("customfield_11210") //deadline CustomField
def now = new Date();
deadLine = new Date(deadLine.getTime())
if(now.compareTo(deadline) >= 0){
final String remoteuser = ComponentManager.getInstance().getJiraAuthenticationContext().getUser().getName();
WorkflowTransitionUtil workflowTransitionUtil = ( WorkflowTransitionUtil ) JiraUtils.loadComponent( WorkflowTransitionUtilImpl.class );
workflowTransitionUtil.setIssue(issue1);
workflowTransitionUtil.setUsername(remoteuser);
workflowTransitionUtil.setAction(441);//Id of the status you want to transition to
workflowTransitionUtil.progress();
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
https://library.adaptavist.com/entity/perform-a-jql-search-in-scriptrunner-for-jira should help with that
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gleb
You can try the following
You need to create a Scriptrunner's Escalation service. Then you will be able to point a JQL query. Something like this: project = 'Some Project' and "deadline" >= startOfDay() and "deadline" <= startOfDay()
Also, you will be able to choose CRON Expression and Action (Transition).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah I've already found Escalation services myself. But thanks anyway!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Show up and give back by attending an Atlassian Community Event: we’ll donate $10 for every event attendee in March!
Join an Atlassian Community Event!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.