I have a script to update an Elements Connect field without affecting "change history" or "last update time", but it only works for single values:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.issue.index.IssueIndexingParams
// Define the custom field ID. CUSTOMFIELD_ID = 333 for the custom field "Platform".
def CUSTOMFIELD_ID = 333
// Retrieve the CustomField object using its ID
CustomField customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(CUSTOMFIELD_ID)
// Define the new value to be set for the custom field
def newValue = 'PT3'
// Define the JQL query to find issues
def jqlQuery = 'key in (ISSUEKEY-101,ISSUEKEY-102)'
// Execute the search with the provided JQL query
Issues.search(jqlQuery).each { issue ->
// Update the custom field value for each issue
customField.updateValue(
null, // No custom field configuration
issue, // The issue being updated
new ModifiedValue(issue.getCustomFieldValue(customField), newValue), // New value for the field
new DefaultIssueChangeHolder() // A holder for changes
)
// Re-index the issue to reflect the changes in the search index
ComponentAccessor.getComponent(IssueIndexingService).reIndex(
issue, // The issue to be re-indexed
IssueIndexingParams.INDEX_ISSUE_ONLY // Re-index only the issue
)
}def newValue = 'PT3,PT8'
results in: {"keys":["PT3,PT8"]}
but what I need is: {"keys":["PT3","PT8"]}
def newValue = ['PT3','PT8']
does not work with: new DefaultIssueChangeHolder()
Any ideas on how to make this work?