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

This widget could not be displayed.

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);

This widget could not be displayed.

There is no call to

indexManager.reIndex(issue);

where indexManager is from: ComponentAccessor.getIssueIndexManager()

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Thursday in United States

Local Atlassian Research Workshop opportunity on Sep. 28th

We're looking for participants for another workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sh...

72 views 0 0
View post

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