This sample shows how to work with choice.
Typically, you use choice column to set columns so that different columns can share the same set of options, which are maintained in one location. Unlike local choice columns which are defined only for a specific column, you can reuse choice. You will also see them used in request parameters in a manner similar to an enumeration.
When you define a choice column by using CreateOptionSetRequest, we recommend that you let the system assign a value. You do this by passing a null value when you create the new OptionMetadata instance. When you define an option, it will contain an option value prefix specific to the context of the publisher set for the solution that the option set is created in. This prefix helps reduce the chance of creating duplicate option sets for a managed solution, and in any option sets that are defined in organizations where your managed solution is installed. For more information, see Merge choice values.
This sample uses the following message request classes to work with choice columns:
The CreateOptionSetRequest
, UpdateOptionSetRequest
, RetrieveOptionSetRequest
, and DeleteOptionSetRequest
messages are intended to be used in a scenario where it contains the data that is needed to work with choice columns.
In order to simulate the scenario described in What this sample does, the sample will do the following:
Checks for the current version of the org.
- The
CreateOptionSetRequest
message creates a choice column required for the sample. - The
CreateAttributeRequest
message creates values linked to the choice column. - The
OptionSetMetadata
message is required to specify theIsGlobal=true
, in order to relate the values to the choice column. - The
UpdateOptionSetRequest
message updates the choice values. - The
PublishXmlRequest
messages publishes the choice column with the latest updates. - The
RetrieveOptionSetRequest
message retrieves the choice column by it's name.
Displays an option to delete all the data created in the sample. The deletion is optional in case you want to examine the data created by the sample. You can manually delete the data to achieve same results.