Uploaded image for project: 'Elements Connect'
  1. Elements Connect
  2. CO-1383

Reference option name of select list in Velocity

    XMLWordPrintable

    Details

    • Functional components:
      Velocity

      Description

      Motivation

      For select lists, it would be great if users could reference options names and not ids with this syntax: $issue.customfield_12345.name

      Custom field types supported:

      • Select list (single)
      • Select
      • checkbox
      • radio buttons

      Impacts

      Query
      New methods on select / checkbox / radio buttons fields:

      • getOptionName() > return a ValueWrapper array of string - the name of the selected option (first option in case of multi select)
      • getOptionNames() > return a ValueWrapper array of string - the names of the selected options (even if the field is single value)
      • getOptionId() > return a ValueWrapper array of string - the array of ID of the selected option (first option in case of multi select)
      • getOptionIds() > return a ValueWrapper array of string - the IDs of the selected options (even if the field is single value)

      Quick example:

      Imagine we have a multi select cf with selected options b (id=10001) and d (id=10003)

      query result comment 
      getOptionNames().get(1)  d  
      getOptionNames().stringList() 'b','d'  
      getOptionNames().size() 2  
      getOptionNames().serialise('-') b-d  
      getOptionNames().getStringValues() [b, d] getStringValues() is giving us the java ArrayList 
      of strings on which we can apply all ArrayList methods
      getOptionNames().getStringValues().contains('b') true  
      getOptionNames().getStringValues().contains('z') false  
      getOptionNames().prefix('*').getStringValues() [*b, *d]  
      getOptionNames().replace('d', 'new').getStringValues() [b, new]  

      ps. the same applies for the getIds() method.


      Original request

      Hello everyone,
      Looks like it is not possible to access directly the content of some JIRA customfield. For example :

      • Create a new Select list JIRA custom field (not nFeed). When trying to access its value with $issue.customfield_XXXX it seems that nFeed retrieves the value's id and NOT its real value.
      • Same appears if you use a JIRA select list cascading custom field, you only retrieve the id of the first field value.

      The workaround is to access the value with the following query :

      SELECT customvalue
      FROM customfieldoption
      WHERE id = $issue.customfield_XXXXX
      

      However this can only work in the case we are working with the JIRA database. If the datasource is something else, then you cannot access its value.

      The workaround in this case is

      • create a new read-only nFeed field which stores the value of the select list customfield
      • create a nFeed field which depends on the value selected in the select list by the help of an intermediate custom field

      which is kind of annoying.

      Can we improve this behaviour ?

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              christophe.prome@valiantys.com Christophe Promé
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: