Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Bulk copy multi select custom field values to another multiselect field

jaya chandra reddy nellore September 14, 2023

I have two multiselect fields i want to bulk update issues from field 1 to field 2 with out updating history.

I have found below script in community but getting issue with that script.

Script:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.customfields.option.*
import com.atlassian.jira.issue.util.*
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.search.SearchQuery
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.issue.ModifiedValue

def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchService = ComponentAccessor.getComponent(SearchService)
def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() as ApplicationUser
def query = jqlQueryParser.parseQuery("project=JAYATP") // Add JQL!!
def results = searchService.search(user, query, PagerFilter.getUnlimitedFilter())

results.getResults().each {documentIssue ->

def issue = issueManager.getIssueObject(documentIssue.id)
def field = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_23400") // change XXXXX with CF ID
def fieldConfig = field.getRelevantConfig(issue)
def Collection targetValues = []

for(val in issue.getCustomFieldValue(field)) {
    if(val.toString() != 'None') {
        targetValues += ComponentAccessor.optionsManager.getOptions(fieldConfig)?.find {
            it.value == val.toString()
        }
    } else {
        targetValues += ComponentAccessor.optionsManager.getOptions(fieldConfig)?.find {
            it.value == 'M3'
        }
    }
}
ModifiedValue mVal = new ModifiedValue(issue.getCustomFieldValue(field),targetValues)
field.updateValue(null, issue,mVal, new DefaultIssueChangeHolder())

}
issue with this line: ModifiedValue mVal = new ModifiedValue(issue.getCustomFieldValue(field),targetValues)
[Static type checking] - Cannot call com.atlassian.jira.issue.ModifiedValue#<init>(java.lang.Object, java.lang.Object) with arguments [java.util.Collection<com.atlassian.jira.issue.customfields.option.Option>, java.util.List<java.lang.Object>]

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
9.4.5
TAGS
atlassian, aafp, jira migration, marketing collaboration, end siloed work, streamline workflows, kerrie gottschalk, jira cloud admins, unified marketing, process visibility, team efficiency, cross-team collaboration

How Kerrie Gottschalk unified AAFP’s marketing team with Jira

At the American Academy of Family Physicians, siloed marketing teams faced delays and duplicate work. Kerrie Gottschalk shook things up by moving the department to Jira, streamlining processes, boosting visibility, and sparking stronger collaboration.

Read the story
AUG Leaders

Atlassian Community Events