Arborescence des pages
Aller directement à la fin des métadonnées
Aller au début des métadonnées

This page resumes the process of migration to SQL Query fields, this includes manual and script implementation to create, configure and copy the value to the new fields.

Initial configuration:

In this phase, you will configure the data source, for more information please check Add Kepler - SQL Query Fields | Grids & Dashboards Datasource page

Map custom fields:

This phase need to be done as a start of the migration process. You will need first to list all your fields that needs to be migrated, you can use the following array pattern :

Old_customfield_IdTypeNew_customfield_id



where :

Old_customfield_id: is the id of all the customfields that needs to be migrated

Type : is the type of the current customfield, can be a simple or multiple select, a table or an autocomplete

New_customfield_id: is the id curresponding to Old_customfield_id (the new field)

Configure field:

After creating all the fields you will need to configure them relying on the old configuration, for more information about how to configure an SQL query field please refer to : Configuration of SQL Custom Field


Copying value:

The last phase is to copy the value from the old to the new fields, for that you can use the following scripts :

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.UpdateIssueRequest
import com.atlassian.jira.issue.fields.CustomField

//This map old to new fields ids
Map<String, String> fieldsMapping = new HashMap<>();
fieldsMapping.put("old_cf_id_1","new_cf_id_1");

// loop over the map where entry.key is the old id and entry.value is the new id
fieldsMapping.each{ entry ->  

	CustomField old_field = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName(entry.key)
	CustomField new_field = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName(entry.value)

	// you can loop on all issues using jql and query searcher
	MutableIssue issue = ComponentAccessor.getIssueManager().getIssueObject("issuekey");
	

	issue.setCustomFieldValue(
			old_field
			, issue.getCustomFieldValue(new_field))
	)

	UpdateIssueRequest updateIssueRequest = UpdateIssueRequest.builder().build();

	ComponentAccessor.getIssueManager().updateIssue(
			ComponentAccessor.getJiraAuthenticationContext().getUser()
			, issue
			, updateIssueRequest)

}




  • Aucune étiquette