Parsware
All articles

How-tos

How to create an option set (choice list)

Create a reusable choice list with a colour and an icon for each value, use it on a field, and see the colours in the form and in every view. How-to video H019, step by step.

A bright cover reading "How-to · H019: Create an option set", with "Choices with colours and icons" under it, the steps Options → Colours → Field → View, and two screens from the video.

How-to H019 · 3 min 15 s. A complete tutorial: every option, colour and icon the video uses, the field that uses the set, and the document the platform saves. Every picture is a frame of the video.

An option set is a list of choices you define once and use on as many fields as you like. In this tutorial you make Lead source, which says where each opportunity came from, with a colour and an icon for each choice, so a list of records reads at a glance.

Before you start

  • The Sales Tracker solution and its Opportunity table, from How to add a field to a table.
  • Two opportunities to try it on. The video uses Contoso fleet renewal and Northwind renewal. Create them in the Sales Tracker app with New if you don't have them.

Part 1: Create the option set

1.1 Name it

  1. Open Solutions, then Sales Tracker, and select Option Sets. Sales stage may already be there, from H017.
  2. Select New.
  3. Type the name: Lead source. The logical name fills in from it: tsp_leadsource.

Read the note. Fields refer to the set by its logical name, so it can't be changed after you save.

1.2 Add the choices

  1. Under Options, type the first choice: Website.
  2. Select the square beside it to set a colour. Pick blue. The panel closes.
  3. Select the round button to set an icon. Search for globe and pick it.
  4. Select Add option for each of the others, and give each its colour and icon:
Option Colour Icon
Website Blue #3b82f6 Globe
Referral Green #22c55e Handshake
Event Orange #f97316 Calendar
Partner Purple #8b5cf6 Users (people)

The New option set panel: Lead source, with four options, Website, Referral, Event and Partner, each with a colour and an icon, their values assigned on save.

1.3 The values

Each choice says assigned on save. You don't type its number: the platform gives each one the next number from your publisher's range. The numbers never change, and a record stores the number, not the label, so renaming a choice later is safe.

1.4 Save

Select Save. Lead source joins Sales stage in the list. Open it again to see the numbers it was given.

Part 2: Use it on a field

  1. Open Tables, then Opportunity, and select New.

  2. Fill in the panel:

    Box Value
    Display name Lead source
    Data type Option set
    Option set Lead source
  3. Select Save.

A field and its option set can share a name: they are different things. A second field, on this table or another, can use the same set.

Part 3: Put it on the form and in the view

  1. Select Forms and open Information. Drag Lead source in, above Sales stage, and select Save.
  2. Select Views and open All Opportunities. Drag Lead source into the columns and select Save.

Part 4: Use it

  1. Open Sales Test's address, open Sales Tracker and open Contoso fleet renewal.
  2. Open Lead source. Each choice shows its colour and its icon.
  3. Pick Referral and select Save & Close.
  4. Open Northwind renewal, pick Website and save it too.

In the view, each lead source reads in its own colour, with its icon: green for the referral, blue for the website.

The All Opportunities view: Contoso fleet renewal with lead source Referral in green, Northwind renewal with Website in blue, each with its icon.

The option set as text

The saved set is one document. The numbers are your publisher's base plus one, two, three, four. With Tailspin Toys' base of 270210000:

{
  "logicalName": "tsp_leadsource",
  "displayName": "Lead source",
  "publisherPrefix": "tsp",
  "optionValueBase": 270210000,
  "options": [
    { "value": 270210001, "displayName": "Website", "color": "#3b82f6", "icon": "Globe" },
    { "value": 270210002, "displayName": "Referral", "color": "#22c55e", "icon": "Handshake" },
    { "value": 270210003, "displayName": "Event", "color": "#f97316", "icon": "Calendar" },
    { "value": 270210004, "displayName": "Partner", "color": "#8b5cf6", "icon": "Users" }
  ]
}

Your numbers may differ: read them on the option set. The field points at the set by name:

{ "logicalName": "tsp_leadsource", "displayName": "Lead source", "dataType": "OptionSet", "optionSet": "tsp_leadsource" }

A script reads and writes the number. For example, to mark an opportunity as a referral in BS Lang:

updateRecord("tsp_opportunity", getRecordRef("record"), { "tsp_leadsource": 270210002 })

If something goes wrong

  • Lead source isn't offered when adding the field. The set wasn't saved, or it is in another environment.
  • The colours don't show in the list. The field isn't in the view. Check Part 3.
  • "Option … cannot be removed: records still hold this value." Change those records to another option first. A removed option's number is retired and never handed out again.

What you built

A coloured choice on the form and in the list, defined once. A second field can use the same set, and a new value added to it appears everywhere at once.

Read more

Is there a task you would like to see done step by step? Tell us. parsware.com/contact