Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

RetrieveOptionSetRequest Class

Definition

Namespace:
Microsoft.Xrm.Sdk.Messages
Assembly:
Microsoft.Xrm.Sdk.dll
Package:
Microsoft.PowerPlatform.Dataverse.Client v1.2.10

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Contains the data that is needed to retrieve a global choice.

public ref class RetrieveOptionSetRequest sealed : Microsoft::Xrm::Sdk::OrganizationRequest
[System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/xrm/2011/Contracts")]
public sealed class RetrieveOptionSetRequest : Microsoft.Xrm.Sdk.OrganizationRequest
[<System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/xrm/2011/Contracts")>]
type RetrieveOptionSetRequest = class
 inherit OrganizationRequest
Public NotInheritable Class RetrieveOptionSetRequest
Inherits OrganizationRequest
Inheritance
RetrieveOptionSetRequest
Attributes

Examples

The following example shows how to use this message. For this sample to work correctly, you must be connected to the server to get an IOrganizationService interface instance.

/// <summary>
/// Retrieves a global choice column by name
/// </summary>
/// <param name="service">Authenticated IOrganizationService instance</param>
static void RetrieveGlobalOptionSetExample(IOrganizationService service)
{

 string globalChoiceName = "componentstate";

 // A boolean global choice: "cardtype_isenabled"; 

 // Use the RetrieveOptionSetRequest message to retrieve 
 // a global option set by it's name.
 RetrieveOptionSetRequest request = new()
 {
 Name = globalChoiceName,
 // MetadataId not used in this example
 };

 // Execute the request.
 var response = (RetrieveOptionSetResponse)service.Execute(request);

 //Write the options:
 switch (response.OptionSetMetadata.OptionSetType)
 {
 case OptionSetType.Picklist:

 var options = (OptionSetMetadata)response.OptionSetMetadata;
 foreach (var item in options.Options)
 {
 Console.WriteLine($"{item.Value}:{item.Label.UserLocalizedLabel.Label}");
 }

 break;
 case OptionSetType.Boolean:
 var booleanOptions = (BooleanOptionSetMetadata)response.OptionSetMetadata;

 Console.WriteLine($"{booleanOptions.TrueOption.Value}:" +
 $"{booleanOptions.TrueOption.Label.UserLocalizedLabel.Label}");
 Console.WriteLine($"{booleanOptions.FalseOption.Value}:" +
 $"{booleanOptions.FalseOption.Label.UserLocalizedLabel.Label}");

 break;
 default:
 // This shouldn't occur
 break;
 }
}

Output:

0:Published
1:Unpublished
2:Deleted
3:Deleted Unpublished 

Sample code on GitHub

Work with choice columns

Remarks

You cannot retrieve choice data for local choice columns using this message. This message only returns data for global ('re-usable') choice columns. Learn more about choice columns

Usage

Pass an instance of this class to the Execute(OrganizationRequest) method, which returns an instance of RetrieveOptionSetResponse.

Privileges and Access Rights

Choice definition information is available for all users.

Constructors

Name Description
RetrieveOptionSetRequest()

Initializes a new instance of the RetrieveOptionSetRequest class.

Properties

Name Description
ExtensionData

Gets or sets the structure that contains extra data. Optional.

(Inherited from OrganizationRequest)
Item[String]

Gets or sets the indexer for the Parameters collection.

(Inherited from OrganizationRequest)
MetadataId

Gets or sets the MetadataId of the OptionSetMetadata to be retrieved. Optional.

Name

Gets or sets the name for the global choice to be retrieved. Optional.

Parameters

Gets or sets the collection of parameters for the request. Required, but is supplied by derived classes.

(Inherited from OrganizationRequest)
RequestId

Gets or sets the ID of the request. Optional.

(Inherited from OrganizationRequest)
RequestName

Gets or sets the name of the request. Required, but is supplied by derived classes.

(Inherited from OrganizationRequest)
RetrieveAsIfPublished

Gets or sets whether to retrieve the metadata that has not been published. Required.

Applies to