Automatic transition based on time

Issue #856 resolved
Antônio Duarte created an issue

I need to run a specific transition in a specific workflow that is used exclusively by a single issue type (this type is named 'Suite'). So, everyday, at 11 PM I must execute this transition for all issues of type 'Suite' in the current project. If some of these issues are in a state that doesn't have THIS transition in particular, nothing will change for this single issue. Is it possible to build such control with JWT?

Thanks in advance. Antonio.

Comments (11)

  1. Fidel Castro Armario repo owner

    Hi @acelsoddbr,

    Sorry, but currently JWT doesn't allow to automatically execute transitions based on a schedule.

    You can try Automation Lite for JIRA, which is a free plugin that allows to do it.

  2. Antônio Duarte reporter

    Thanks for your support. I'll look for it at Automation Lite. Anyway, I think this could be a good improvement to JWT to be put in the product roadmap! Greetings. Antonio.

  3. Antônio Duarte reporter
    • changed status to open

    Hi, @fcarmario , I'm reopening the issue due: I found in Automation Lite the possibility to run the desired transition once a day. Now, at this transition I need to update a complex custom field (from the TableGrid add-on) and this can be accomplished by running a groovy script. How can I configure a post-function in this transition to run such script? Thanks in advance. Antonio

  4. Antônio Duarte reporter

    The groovy expression was given by the TableGrid support team, and it is shown below. Their support was based on Adaptavist Scriptrunner. I would like also to know if JWT can run the same type of groovy script:

    import com.atlassian.jira.component.ComponentAccessor import groovy.sql.Sql import org.ofbiz.core.entity.ConnectionFactory import org.ofbiz.core.entity.DelegatorInterface import java.sql.Connection import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.fields.CustomField import com.atlassian.plugin.PluginAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.security.JiraAuthenticationContext import com.atlassian.jira.user.ApplicationUser import com.atlassian.crowd.embedded.api.User

    // Adding jira classes through reflection User user = ComponentAccessor.getUserManager().getUserByKey("admin").getDirectoryUser() CustomFieldManager customFieldManager = ComponentAccessor.getOSGiComponentInstanceOfType(CustomFieldManager.class) / Specify this field with your Table Grid Editor custom field name / CustomField tgeCustomField = customFieldManager.getCustomFieldObjectsByName("tge-suite-issues").get(0) Long tgeCustomFieldId = tgeCustomField.getIdAsLong()

    PluginAccessor pluginAccessor = ComponentAccessor.getPluginAccessor() Class dataManagerClass = pluginAccessor.getClassLoader() .findClass("com.idalko.jira.plugins.igrid.api.data.TGEGridTableDataManager") def tgeGridDataManager = ComponentAccessor.getOSGiComponentInstanceOfType(dataManagerClass)

    def delegator = (DelegatorInterface) ComponentAccessor.getComponent(DelegatorInterface) String helperName = delegator.getGroupHelperName("default")

    / Actual Sql query that selects count of 3 issue statuses: To Do, Done, In Progress On "where ji.project=10000 AND ist.pname='Suite'" line you have to specify assignment of ji.project to your actual project id Query selects issue statuses only for issue type: Suite. Code that corresponds to that condition is "ist.pname='Suite'" / def sqlStmt = """ SELECT sum(case when iss.pname='To Do' then 1 else 0 end) as todo, sum(case when iss.pname='Done' then 1 else 0 end) as done, sum(case when iss.pname='In Progress' then 1 else 0 end) as in_progress FROM "jiraissue" ji JOIN "issuestatus" iss on iss.id=ji.issuestatus JOIN "issuetype" ist on ji.issuetype=ist.id where ji.project=10000 AND ist.pname='Suite' """

    // Opening connection and creating sql query Connection conn = ConnectionFactory.getConnection(helperName) Sql sql = new Sql(conn)

    // Getting 3 variables of our issuestatuses with sql query int toDoCount int doneCount int inProgressCount try { sql.eachRow(sqlStmt) { toDoCount = it.todo doneCount = it.done inProgressCount = it.in_progress } } finally { sql.close() }

    // Adding row to our TableGridEditor custom field Map<String, Object> row = new HashMap<String, Object>() def total = toDoCount + doneCount + inProgressCount row.put("idate", new Date().getTime()) row.put("itoDo", toDoCount) row.put("iInProgress", doneCount) row.put("iDone", inProgressCount) row.put("iTotal", total) / Here you have to specify key of your issue with issuetype 'Management' / Issue issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("TEST-14") tgeGridDataManager.addRows(issue.getId(), tgeCustomFieldId, Arrays.asList(row), user)

  5. Fidel Castro Armario repo owner

    Hi @acelsoddbr,

    Sorry, but JWT doesn't any functionality for executing groovy scripts.

  6. Log in to comment