Controlling text displayed for options in a dropdown in a form

I’m trying to find documentation for a feature I learned about quite a while ago. It is possible to control the text displayed for each option in a dropdown by returning a list of lists from the AllowedValuesDefinition. For example, the sample code below will create a dropdown field where selecting “Name 1” will set the field value to “id1”, while selecting “Name 2” will result in a field value of “id2”. I can’t find any documentation for this. I want to encourage developers I work with to prefer object ids over object names since names change and ids change… less. However, it will be a hard sell if I can’t find any indication that this is a supported feature.

<Field displayName="My Selection" dynamic="true" name="mySelection" type="string">
  <AllowedValuesDefinition>
    <Script>
      <Source>
        return Arrays.asList(
          Arrays.asList("id1", "Name 1"),
          Arrays.asList("id2", "Name 2")
        );
      </Source>
    </Script>
  </AllowedValuesDefinition>
</Field>
1 Like

You can find this in the new official documentation site, albeit in a slightly different format - but it should get the point across.

Fields (sailpoint.com)

1 Like

Forms whitepaper: Multi-lingual Allowed-values Lists

Paul’s method is a good option. Another option is to create a hidden field in the form with a dependency reference on your “displayed” field and effectively translates the display-name to the id using a field value rule/script:

<Field displayName="My Selection" dynamic="true" name="mySelection" type="string">
  <AllowedValuesDefinition>
    <Script>
      <Source>
        return Arrays.asList(
          Arrays.asList("id1", "Name 1"),
          Arrays.asList("id2", "Name 2")
        );
      </Source>
    </Script>
  </AllowedValuesDefinition>
</Field>

<Field displayName="My Selection ID" dynamic="true" name="mySelectionID" type="string" hidden="true" dependencies="mySelection">
    <Script>
      <Source>
         return getIdFromField(mySelection);
      </Source>
    </Script>
</Field>

Thank you everyone! I chose Paul’s answer because although Alex’s answer has more info right in the reply, that documentation doesn’t state outright that you can return a list of lists (even though that is what the example code does). The Forms whitepaper specifically states that it can be a list of lists, gives an example of the list structure for a hard-coded set of AllowedValues, and then says that you can also return a list-of-lists from an AllowedValuesDefinition. It’s just a bit more obvious that this is documented behavior.

1 Like