CreateOptionSetRequest Class
Definition
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 create a new global choice.
public ref class CreateOptionSetRequest sealed : Microsoft::Xrm::Sdk::OrganizationRequest
[System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/xrm/2011/Contracts")]
public sealed class CreateOptionSetRequest : Microsoft.Xrm.Sdk.OrganizationRequest
[<System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/xrm/2011/Contracts")>]
type CreateOptionSetRequest = class
inherit OrganizationRequest
Public NotInheritable Class CreateOptionSetRequest
Inherits OrganizationRequest
- Inheritance
- 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>
/// Demonstrates creating a global choice
/// </summary>
/// <param name="service">The authenticated IOrganizationService instance</param>
static void CreateOptionSet(IOrganizationService service) {
// Solution and language information
string solutionUniqueName = "SolutionName";
string prefix = "sample";
int languageCode = 1033; //English
string choiceName = $"{prefix}_status";
Label choiceLabel = new("Status", languageCode);
CreateOptionSetRequest request = new() {
OptionSet = new OptionSetMetadata {
Name = choiceName,
DisplayName = choiceLabel,
IsGlobal = true,
OptionSetType = OptionSetType.Picklist,
Options = {
new OptionMetadata(new Label("Open",languageCode),null),
new OptionMetadata(new Label("Suspended",languageCode),null),
new OptionMetadata(new Label("Cancelled",languageCode),null),
new OptionMetadata(new Label("Closed",languageCode),null)
}
},
SolutionUniqueName = solutionUniqueName
};
var response = (CreateOptionSetResponse)service.Execute(request);
Console.WriteLine($"Created OptionSetId:{response.OptionSetId}");
}
Sample code on GitHub
Remarks
Usage
Pass an instance of this class to the Execute(OrganizationRequest) method, which returns an instance of CreateOptionSetResponse.
Privileges and Access Rights
To perform this action, the caller must have the prvCreateOptionSet
privilege that is included in the System Administrator and System Customizer roles.
Constructors
CreateOptionSetRequest() |
Initializes a new instance of the CreateOptionSetRequest class. |
Properties
ExtensionData |
Gets or sets the structure that contains extra data. Optional. (Inherited from OrganizationRequest) |
Item[String] |
Gets or sets the indexer for the |
OptionSet |
Gets or sets the definition of the global choice. Required. |
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) |
SolutionUniqueName |
Gets or sets the name of the unmanaged solution you want to add this global choice to. Optional. |