how would i create a custom field that stores both Text and Numbers

mary benben April 24, 2014

My Custom (numeric) Field, "Change ID" now needs to store text as well as numbers. I don't believe i can change the currentl logic and was therefore going to create a new custom field. However, I'm not seeing within the current list of Cumstom Fields in JIRA 6.2 where this fuctionality is available. Please advise.

3 answers

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 24, 2014
That would mean the field would no longer accept text. It would be safer and easier to just use a numeric field.
0 votes
Mizan
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.
April 24, 2014

You can create a text type customfield and add a javascript validation to the field which will allow only alphanumeric entries.You can do this by adding the javascript in the field description

What about the existing values in the customfield ? you will need to migrate those values to the new customfield. refer this doc

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 24, 2014

You need to create a custom field *type* in a plugin.

Numeric field is one type of custom field, as is text, select, multi-select and so-on. You need to write a plugin that will provide "number or text" type field

However, the mixed data type really isn't supported in Jira's back end - it kind of expects you to have one type of data, so you can't really use the standard API calls, you'll need to write your own. Or just store the information as a string irrespective of type.

Or, just use a string, as that can store numbers or text already.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 24, 2014

I've just thought again.

You've got a compounded problem here. Whether you swap to a simple text field or write a new field, you are not going to be able to change the type of the existing field. You can add a new field of the new type, but you'll need to migrate your data into it.

You can change field types in the database, if you are very very careful (proven backups, Jira offline, reindexing afterwards), but this could be a bit of a trek because number fields are stored in one way and moving to a string or whatever structure you write is probably going to require data migration.

Suggest an answer

Log in or Sign up to answer