Copy custom field values into summary field

We're not going to be using a custom field anymore, and we want to copy the value of this field into the Summary field.

The custom field is called Project Title; we want to make these titles the Summary of individual tickets. But the built-in scripts in Script Runner don't seem to allow themselves to be used on the Summary field. Bulk operations don't seem to be the solution, as it doesn't work on Summary either and needs to pull the value from field-to-field individually.

Is there a usable workaround?

2 answers

I have an example of a SQL based solution, which I used for a migration from a multi-version custom field to "Fix Version/s".  That could be readily adapted for a string-to-string copy.

Alternately, if I had to do that over, I'd probably write an ad-hoc script runner script that loops over the issues and updates the value.  This has the advantage of not requiring a re-index, but it could time out depending on how many issues it has to process at the same time.

Finally, similar to the ad-hoc script, you could add a self referencing transition to the workflow, and make that a post function.  It would still require some scripting, but less than the ad-hoc version as you'd be given the 'issue' to work on.  From there, you could bulk transition the issues you want to perform the migration on.

The SQL, for reference, was:

delete from nodeassociation where source_node_entity='Issue'
and association_type='IssueFixVersion'
and source_node_id in (select issue from customfieldvalue where customfield=11122);

insert into nodeassociation(source_node_id, source_node_entity, sink_node_id, sink_node_entity, association_type) select issue,'Issue',numbervalue,'Version','IssueFixVersion' from customfieldvalue where customfield=11122;

As I look at that, it's a lot more complicated, since FixVersion is a nodeassociation, and not a field of "issue".  You'd probably just want to pull a list of every issue that has a customfieldvalue for the customfield in question, and craft a direct update based on the contents of the customfield.  Or, directly:

update jiraissue i set summary=(select stringvalue from customfieldvalue cfv where customfield=X and cfv.issue=i.id) where i.id in (select issue from customfieldvalue where customfield=X);

To test that on one issue, add:

update jiraissue i set summary=(select stringvalue from customfieldvalue cfv where customfield=X and cfv.issue=i.id) where i.id in (select issue from customfieldvalue where customfield=X) and i.id=Y;

Where Y is the ID of a specific JIRAISSUE, as fetched by:

select id from jiraissue where issuenum=ZZZZ and project=(select id from project where pkey='KEY');

Thank you; I'll have to give this a try on another machine which allows me SQL access to the database.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,241 views 14 19
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot