We are trying to consolidate project-specific custom description fields into the 'Description' system field to have a streamlined workflow.
I have read through this existing question about copying system field to custom field, but I cannot get it to work in the other direction: https://community.atlassian.com/t5/Jira-questions/copying-values-of-System-field-to-Custom-field/qaq-p/610962
I believe I've found the correct methods to use by following the answers in this other question:
https://community.atlassian.com/t5/Answers-Developer-Questions/How-to-update-issue-and-set-assignee/qaq-p/552423
I'm able to get the data from the custom field, but this isn't updating the system field. Could someone help point out how I'm messing up the final line parameters, or if I'm missing some additional input:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.bc.issue.IssueService
import org.apache.log4j.Logger
import org.apache.log4j.Level
log.setLevel(Level.DEBUG)
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser.class)
def searchProvider = ComponentAccessor.getComponent(SearchProvider.class)
def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def query = jqlQueryParser.parseQuery("project = PACE AND summary ~ testscriptrunner") // change query to match the issues you want to update
def results = searchProvider.search(query, user, PagerFilter.getUnlimitedFilter()) // get results of query
results.getIssues().each {documentIssue -> // go through each issue
def issue = issueManager.getIssueObject(documentIssue.id)
log.debug("----------------------")
log.debug(documentIssue.key)
log.debug("Current Description Value: " + documentIssue.description)
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObjectByName("Story Description");
def newValue = issue.getCustomFieldValue(customField)
log.debug("Current Story Description Value: " + newValue)
def issueService = ComponentAccessor.getIssueService()
def issueInputParameters = issueService.newIssueInputParameters()
//customField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(customField), documentIssue.description),new DefaultIssueChangeHolder()); // copy description to story description - working
issueInputParameters.setDescription("newValue"); //copy story description to description - not working
}
I'm not receiving any error, it just won't update the Description even when setting a dummy value