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

0 votes
Accepted answer

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

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 Tuesday in United States

Topic Tuesday: What's your favorite topic?

Good morning All, Our goal is to get you into the habit of while enjoying your favorite morning drink you are checking the NOVA "space" for topics and comments. Your input is really needed and...

60 views 4 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