Re-index customfield values in JIRA 4.4

Hello, i update custom field value in parent issue via Groove script (post-function in transition) in JIRA 4.4.3. After the value is updated, then i see in filter old value.

Can you tell me what i doing wrong? Thank you.

Here is my code:

import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.ModifiedValue;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder;
import com.atlassian.jira.issue.util.IssueChangeHolder;
import com.atlassian.jira.workflow.WorkflowTransitionUtil;
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl;
import com.atlassian.jira.util.ImportUtils;
import com.atlassian.jira.util.JiraUtils;
import com.opensymphony.workflow.WorkflowContext;

String stateFieldId = "customfield_13300";

CustomFieldManager cfm = ComponentAccessor.getCustomFieldManager();
WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil)JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class);
CustomField stateField = cfm.getCustomFieldObject(stateFieldId);

parent = issue.getParentObject();

Object oldValue = parent.getCustomFieldValue(stateField);
Object newValue = 2;

// Store the current state of indexing
Boolean wasIndexing = ImportUtils.isIndexIssues();

// Set indexing to true
ImportUtils.setIndexIssues(true);

// Do your changes on issue here!
stateField.updateValue(null, parent, new ModifiedValue(oldValue, newValue), new DefaultIssueChangeHolder());

// Reset Indexing
ImportUtils.setIndexIssues(wasIndexing);

2 answers

1 accepted

Thank you. For me works (JIRA 4.4.3):

IssueIndexManager indexManager = ComponentManager.getInstance().getIndexManager();

// Store the current state of indexing
Boolean wasIndexing = ImportUtils.isIndexIssues();

// Set indexing to true
ImportUtils.setIndexIssues(true);

// Do your changes on issue here!
stateField.updateValue(null, parent, new ModifiedValue(oldValue, newValue), new DefaultIssueChangeHolder());
indexManager.reIndex(issue);

// Reset Indexing
ImportUtils.setIndexIssues(wasIndexing);

0 vote

There is no call to

indexManager.reIndex(issue);

where indexManager is from: ComponentAccessor.getIssueIndexManager()

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted yesterday in Confluence

Calling all marketing teams who use Confluence - we want to hear from you!

Hi Community! me again 🙂 If you’re a marketing team using Confluence, we want to hear your story! How did you start using Confluence? What are your use cases? What have been some of the benefits?...

97 views 3 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you