Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,458,283
Community Members
 
Community Events
176
Community Groups

Migrate Insight objects (multiple) (legacy) custom fields to Insight objects custom fields

This Community post provides a possible workaround to migrate Insight objects (multiple) (legacy) custom fields to Insight objects custom fields.

The Groovy script can be executed, for example from the Insight Script Console

It has been tested in Jira 8x

You should plan a maintenance window when you are migrating the fields in order to have a clean and effective migration without interruptions.

Groovy code example:

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.event.type.EventDispatchOption;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.web.bean.PagerFilter;
import com.atlassian.jira.issue.search.SearchResults;

def projectManager = ComponentAccessor.getProjectManager();
def issueManager = ComponentAccessor.getIssueManager();
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
def searchService = ComponentAccessor.getComponentOfType(com.atlassian.jira.bc.issue.search.SearchService);
def jqlQueryParser = ComponentAccessor.getComponentOfType(com.atlassian.jira.jql.parser.JqlQueryParser);

def deprecatedInsightCustomFieldId = *****;
def newInsightCustomFieldId = *****;

/* Change the custom field id's accordingly to your environment and the custome fields you want to migrate */
def deprecatedInsightCustomField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(deprecatedInsightCustomFieldId);
def newInsightCustomField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(newInsightCustomFieldId);

def query = jqlQueryParser.parseQuery("cf[" + deprecatedInsightCustomFieldId + "] is not EMPTY");
def searchResults = searchService.search(currentUser, query, PagerFilter.getUnlimitedFilter());

log.warn("Issues to be updated: " + searchResults.getTotal());
searchResults.getResults().each { issue ->
MutableIssue mi = (MutableIssue) issueManager.getIssueObject(issue.getId());
def insightObjects = mi.getCustomFieldValue(deprecatedInsightCustomField);
if (insightObjects != null && !insightObjects.isEmpty()) {
mi.setCustomFieldValue(newInsightCustomField, insightObjects);
ComponentAccessor.getIssueManager().updateIssue(currentUser, mi, EventDispatchOption.DO_NOT_DISPATCH, false);

log.warn("Changed issue: " + mi + ", set new custom field with values: " + insightObjects);
}
}

 

Result

We migrated from "MigrateSourceMultiple" custom field to "Insight New"

Screenshot 2022-02-22 at 16.15.31.png

0 comments

Comment

Log in or Sign up to comment
TAGS

Atlassian Community Events