JIRA Custom Field for Fix Versions

Hi all,

I have inherited a situation where there were custom fields created called "Found in release"  and "Fix in Release".    Fix version/s and affected version/s are empty. 

To take advantage of all of JIRA's links and tools I would like to undo this, and move all values in "Found in Release" to "affected version/s" and all values in "Fix in release" to "fix version/s".  

I would assume a database "hack" (or copy really) could probably accomplish this but I am not a DBA.

Any ideas on how best to accomplish this.

Thanks in advance!

Robert

4 answers

1 accepted

Accepted Answer
2 votes

Can you create transitions from each status back to itself and make the assignments in post-functions, then do Bulk Transitions? Tedious, perhaps, but safer than messing with the DB.

Sten

So you have to do this for each and every status, for each and every workflow, and for each and every project? If so wow, that would be over 100 new transitions. And then I would have to transition each issue through that transition? Can I do that? So here is my concern, I have 20 status's per workflow, status 1 has a transition called move-fields, status 2 has a similar transition. Can I bulk transition Issues in status 1 to status 1's move-fields and and issues in status 2 to status 2's move-fields at the same time? Or would each one have to be done separately? It may be easier to go into each and every issue and just copy the field. I think this would be a great plugin. Copy field, that for whatever projects specified, takes all the issues in each project and has a from field and a to field (they would have to be the same field type of course.)

With that amount of transitions, extremely tedious, granted. Not sure if there are any plugins that will do the trick, but maybe someone at your site can write something using the JIRA API? Find the issues to modify using a filter, then one by one read the issue, update the fields. I have used Python scripting and others in the company use PHP, both work fine. Once complete, maybe create post-functions on Create transition(s) to copy the fields as long as some people are set in their ways.

Maybe scriptrunner can be used, I've never tried using it myself to run scripts outside of transitions.

I am the Atlassian resource here. I do know python and shell scripts. Possibly use Bob's CLI with some scripting to copy it. Hmm... Thanks, will give it a try.

The SQL solution is fairly straightforward, I've done it for the transition in the other direction (FixVersion to a Custom Field).  However, it will require digging; I can provide the 'other direction' sample, but someone will have to figure out the IDs of the custom fields and the appropriate sub-SELECT for the insert.  Example:

insert into customfieldvalue (
select @rownum:=@rownum+1 as rownum, cfv.*
FROM (
 select source_node_id as issue,
 (select id from customfield where cfname='Release Version/s') as customfield,
 null as parentkey,
 null as stringvalue,
 sink_node_id as numbervalue,
 null as textvalue,
 null as datevalue,
 null as valuetype
 from nodeassociation
 where source_node_id in (select id from jiraissue where project in (10,11,12) and issuestatus in (5,6))
 and source_node_entity='Issue'
 and sink_node_entity='Version'
 and association_type='IssueFixVersion'
 and sink_node_id in (select id from projectversion where project in (10,11,12) and vname not like '%Sprint%' and vname not like '%Backlog%' and vname not like '%.x')
 and (source_node_id,(select id from customfield where cfname='Release Version/s'),sink_node_id) not in (select issue, customfield, numbervalue from customfieldvalue)
 ) cfv,
(SELECT @rownum:=(select max(id) from customfieldvalue)) r
);
update SEQUENCE_VALUE_ITEM set SEQ_ID=(select max(id) from customfieldvalue) where SEQ_NAME='CustomFieldValue';

There are some optional restrictions here; for example, we didn't want to copy Sprint or Backlog versions.  A "copy all for all projects" would be more straightforward.  Basically, you'd insert into nodeassociation a select from the appropriate customfield value, once for Fix Version/s and once for Affect Version/s.  If you need help with it, I can probably work out the exact SQL for an unfiltered dump, it would take about half an hour, give or take.

Wow thank you. I can get the custom field IDs, but am still a little shy of doing it through the MySQL DB. I write pretty advanced bash scripts and so I will give that a try first with Bob Swift's CLI. Seems straight forward. Foreach issue that meet criteria, Version=`read field Release version`, set Fix version/s to $Version.

Not an answer, but a +1 for the question.  I have a custom text field that holds the value of Affects Version and I want to copy that value into Affects Version for all projects. Appreciate any guidance

 

Sorry, more or less a repeat of my old answer.

Unless you want to do scripting, here is a possible but cumbersome workaround. For each status in the workflow where you have this issue, create a transition that goes back to the same status, copying the values from both custom fields to the system fields in post-functions.

Maybe add a condition on who can run this, but it shouldn't hurt anything and would be idempotent as long as no one modifies the custom fields.

Test on an issue or two because I'm not sure how the copy from a text field into a version field works, then do bulk transitions.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 25, 2018 in Jira

Atlassian Research Workshop opportunity on Sep. 28th in Austin, TX

We're looking for participants for a workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sha...

419 views 7 5
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you