Uploaded image for project: 'Elements Connect'
  1. Elements Connect
  2. CO-3614

Connect fields updated thought an Automation rule are not properly indexed

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Done
    • Affects Version/s: 5.13.29, 6.0.7, 6.1.5
    • Fix Version/s: 6.1.11
    • Labels:
      None
    • Environment:

      Automation 6.0.4 - 6.0.6 - 7.0.4
      Jira 7.12.3 - 8.3.1

    • Functional components:
      3rd party - Automation for Jira

      Description

      How to reproduce

      Setup

      • Install Automation latest version (tested with 6.0.4 & 6.0.6)
      • Configure a connect field "Connect field":
        • Datasource: Jira SQL
        • Query: select summary from jiraissue where id = $issue.id
        • Readonly - single value
        • Template: {0}
      • Add the Connect field to the edit / view screens of an issue
      • Configure an Automation task:
        • Trigger: Issue is commented
        • Action: Run "Set connect field action" on the "Connect field"

      Steps

      • Create an issue ISS-1 with summary "hello"
      • Set the Connect field value on this issue (manually)
      • In the issue navigator, execute JQL: "Connect field" = "hello" - ISS-1 is returned
      • Edit the issue summary, change to "salut"
      • Post a comment on ISS-1
      • In the issue navigator, execute JQL: "Connect field" = "salut"

      Current
      No issue returned

      • If we search for "Connect field" = "hello", ISS-1 is returned (previous value of the field)
      • If we reindex Jira, "Connect field" = "salut" returns ISS-1

      >> apparently the issue is not (properly ?) indexed when the Connect field is updated

      Note

      • Same behaviour with Datetime fields (haven't tried other fields)
      • Same behaviour when the Automation rule is executed periodically
      • No error when an Automation rule is executed on issue creation

      Workaround

      With ScriptRunner:

      • Create a scheduled Automation rule that triggers a custom event previously created for this purpose (eg. "Auto reindex")
      • Create a Script Listener that listens to this event, and use this piece of code:
        import com.atlassian.jira.component.ComponentAccessor
        import com.atlassian.jira.issue.Issue
        import org.ofbiz.core.entity.GenericValue
        import com.atlassian.jira.issue.index.IssueIndexManager
        import com.atlassian.jira.util.ImportUtils
        import org.apache.log4j.Category
        
        Category log = log
        log.setLevel(org.apache.log4j.Level.DEBUG)
        
        def projectManager = ComponentAccessor.getProjectManager()
        def indexManager = ComponentAccessor.getComponent(IssueIndexManager)
        def issueManager = ComponentAccessor.getIssueManager()
        def project = projectManager.getProjectByCurrentKey("CLI") // Your project Key here
        
        log.debug("=> Starting reindex for CLI project...")
        for (GenericValue issueValue : issueManager.getProjectIssues(project.genericValue)){
            Issue i = issueManager.getIssueObject((Long) issueValue.id)
            boolean wasIndexing = ImportUtils.isIndexIssues()
            ImportUtils.setIndexIssues(true)
            log.debug("Reindex issue ${i.key}")
            indexManager.reIndex(issueManager.getIssue(i.id))
            ImportUtils.setIndexIssues(wasIndexing)
        }
        log.debug("=> Reindex for CLI project is now complete.")
        

      Note to devs
      In the code, we use the IssueManager instead of IssueService to update issue with Connect fields values. Issue service allows to rendex issue whereas Issue manager does not.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              christophe.prome@valiantys.com Christophe Promé
              Votes:
              3 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: