Hi,
Is it possible to just update an issue without modifying the data. The reason is that we are using Power Database Custom Fields and when the Custom Field data collected from the database is changed i would like to update the Jira Issues which has this customfield set to the new value.
You want to update issue or custom field(like add option from db to select list)?
Hi,
The custom field in Jira is a Database Custom Field which collects the data of a value in a database of a person responsible for the customer. When the database value changes the field is not changed in Jira until i update issue and save.
What i guess happens is that when i edit an issue the database query which collects the value is run again.
The end result is that I would like this to happen on a schedule every night. But first i need to find a method which updates the issue and by updating the issue makes Jira run the database query again
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try this:
ApplicationUser user = userManager.getUserByName("UserName");
CustomField customField = customFieldManager.getCustomFieldObjectByName("customFieldName");
def CustomFieldValue = issue.getCustomFieldValue(customField);
IssueChangeHolder changeHolder = new DefaultIssueChangeHolder();
customField.updateValue(null, issue, new ModifiedValue(CustomFieldValue, user), changeHolder);
or this:
issue.setCustomFieldValue(CustomField,CustomFieldValuetoset);
issue.store()
Maybe try to reindex after the update:
import com.atlassian.jira.issue.index.IssueIndexingService import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.util.ImportUtils import org.apache.log4j.Category def issueManager = ComponentAccessor.getIssueManager() def issueIndexingService = ComponentAccessor.getComponent(IssueIndexingService) boolean wasIndexing = ImportUtils.isIndexIssues(); ImportUtils.setIndexIssues(true); log.warn("Reindex issue ${issue.key} ${issue.id}") issueIndexingService.reIndex(issueManager.getIssueObject(issue.id)); ImportUtils.setIndexIssues(wasIndexing);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Erik,
Try this:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.UpdateIssueRequest
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
ComponentAccessor.getIssueManager().updateIssue(currentUser, issue, UpdateIssueRequest.builder().build())
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Thanks we have tried something similar but it seems the custom field does not update even though the PostFunction is applied.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.