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);
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);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.