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

[Resolved] Change ID on a Elements Connect field

Roman Holdener September 8, 2023

Dear Community

I am currently facing a problem I need to solve:

Quite a while ago, I created an Elements connect field that lets the user choose one or multiple teams (it is used for Features, to indicate, which team is working on it). Young and unexperienced as I was back then, I just used "select NAME from table_containing_teams" 

This worked quite fine, until the first team changed its name. As the team name was also the ID stored in jiras DB, when the name of a team changes on the source DB, all the values that were selected in jira issues will be lost.

The teams on the source DB do have an ID row, wich contains a unique ID that does not change, when the team name changes. Therefore it would be way better to use the ID from the source DB as ID in Elements Connect.

Meanwhile, there are thousands of issues using the mentionned field. If I would just adapt the SQL query for the Elements Connect field and use the object ID as ID in jira, all of the values on those tickets will be lost. However, I will have to change this configuration to avoid future administrative overhead.

Does anyone have an Idea, how this issue can be fixed, without using any data or having to manually edit all the issues using the field in Question?

3 answers

2 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Roman Holdener January 22, 2024

Thank you for your answers. Using a groovy script is tricky, as, depending on the configuration in Elements Connect, always eighter the name or the code is the key.

To resolve this, we temporalry created a new Elements Connect field and copyed all the values to this field. Than we changed the ID on the original field and migrated the values back to the original field using the newly created field as source.

0 votes
Answer accepted
Peter-Dave Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 8, 2023

You should be able to write a short groovy script to go through all issues that have a value in your Elements Connect fields and replace the team name with the team id.

I have never used Elements Connect field, so I can't provide details about that.

0 votes
Joel Batac November 6, 2023

I had similar case where I had to update 1000's of ticket. Maybe you can use this.

What I did was searched for the issues (yours could be project = PROJECTNAME and team = TeamName). Once you have the list of issues, you can do below. 

 

import com.atlassian.jira.component.ComponentAccessor
def pluginAccessor = ComponentAccessor.getPluginAccessor();
def plugin = pluginAccessor.getPlugin("com.valiantys.jira.plugins.SQLFeed");
def serviceClass = plugin.getClassLoader().loadClass("com.valiantys.nfeed.api.IFieldValueService");
 
def fieldValueService = ComponentAccessor.getOSGiComponentInstanceOfType(serviceClass);
 
def customFieldId = "customfield_29801"; //your EC field
def map = [
'PROJECTNAME-4103':'NEW_Team_Name', //EC Value to put
'PROJECTNAME-3529':'NEW_Team_Name',
'PROJECTNAME-4954':'NEW_Team_Name',
'PROJECTNAME-7132':'NEW_Team_Name',
'PROJECTNAME-4476':'NEW_Team_Name',
'PROJECTNAME-4103':'NEW_Team_Name',
'PROJECTNAME-4476':'NEW_Team_Name'
]
map.each { issueKey, connectKeyValue ->
fieldValueService.setFieldValue(issueKey, customFieldId, connectKeyValue);
}
TAGS
AUG Leaders

Atlassian Community Events