Is it possible to have custom field options with a value different than the label?

Hello!

I am trying to create a custom field option (context, no apps) having a value different than the label. When creating an option you can specify value, which is used as value and label for the option. Is it possible to specify both things? For instance, I would like the user to see an option with label ADMINISTRATOR and value administrator.

I know you can have additional information in the options if you are using custom fields created by a connect app, but that will not work for me, since there will a variable number of custom fields.

Thank you!

Hello @LeandroPelorosso

Assuming you are talking about creating an option within a custom field of the type Select List, can you please explain what a ‘label’ is? Is it something that you have seen appear in the web UI or in the rendered HTML of the page? Can you provide a screen grab that shows the label in action?

As far as I know, each option in a Select List field only has one parameter, value. There is no parameter or object called label. If this label parameter or object can be created or altered in a Connect app, can you provide a link to the documentation that describes it?

Maybe you’re getting confused with the custom field type called Labels?

Hello! Thank you for your reply!

Historically, a Select List option has two properties: value and label. The Label is what the user sees, the text rendered as the option, and value is a unique code identifying said option. You can see this in, for instance, react-select, or even in plain html.

Sometimes it is useful to have a value identifying the option, that is different from the label itself.
For instance, in a stock management application, you could have a Select List to pick products, in which the label is the name of the product, and the value is the SKU of said product.

I was wondering if there is a workaround for this, a way to specify both things when creating a context custom field option.
My guess is that it is not possible, since the documentation says nothing about this, but I thought I should ask.

On the other hand, the documentation also mentions custom fields created by a connect application.
For a Select List created by a connect app, you can create options with a value (which acts as a label, what the user sees), and additional properties. In this case, you could use value as a label and store, following the previous example, the SKU as an additional property.
But this only works for custom fields created by connect apps, and it is not a viable solution for me.

Thank you! :slight_smile:

Hello @LeandroPelorosso

You seem to be now talking about a different thing. You seem to be talking about a HTML select element and the use of the option label, that can be used to render drop-down lists with options on a page, like this:

<select id="pets" name="My pets">
  <option label="dog">Big hairy dog</option>
  <option value="cat">Small fluffy cat</option>
</select>

The existence and use of the attributes value vs label for the options is all historical HTML stuff.

Given that Jira doesn’t render custom fields like Select List on a HTML page using those historical select elements, but as div elements with their appearance and content controlled using abstracted CSS classes, like this:

<div class="css-1v0cd8t">
  <button aria-label="Edit State" type="button" class="css-1kh4s4h"></button>
    <div data-read-view-fit-container-width="true" class="css-1dtwgr">
      <div class="sc-1g3b8uu-1 GIbXx">Small fluffy cat</div>
    </div>
</div>

then there is no HTML select element on the page, so there is nowhere that any of those historical HTML attributes value or label would appear anyhow.

Jira’s Select List custom field supports only a single parameter for its options, not two, so there is nowhere for a secondary parameter to be stored for the REST API to be able to put any data in it. There are the additional parameters optionId and disabled that the REST API can set, but neither of them affect what is shown in the option’s ‘value’ that is displayed on the screen to the user.

If you know of a way to use Connect to make Jira’s custom field options hold a supplementary parameter and for values in that parameter to be rendered in the HTML to the user, then that is a great outcome for you, but since the REST API has access to only the single value parameter, as per the REST API documentation, then it is reasonable to assume that is the limit of what can be achieved.

Thank you for taking the time to write.

I agree with everything you said. It is clear that Jira does not render elements like a Select List in HTML, and I wasn’t really expecting that. But that would not forbid them from allowing us to specify additional information associated to an option.

I just found it odd that they allow you to specify only an option’s label, without the possibility of associating a different underlying value to it. I am sure they had their reasons, though, and the documentation is very clear about this, only label (which they call value) is accepted. This being said, in case I was missing something, I thought I should ask.

Thank you again! :slight_smile: