Κοινή χρήση μέσω


UpdateOptionSetRequest Class

Definition

Contains the data that is needed to update the definition of a global choice.

public ref class UpdateOptionSetRequest sealed : Microsoft::Xrm::Sdk::OrganizationRequest
[System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/xrm/2011/Contracts")]
public sealed class UpdateOptionSetRequest : Microsoft.Xrm.Sdk.OrganizationRequest
[<System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/xrm/2011/Contracts")>]
type UpdateOptionSetRequest = class
    inherit OrganizationRequest
Public NotInheritable Class UpdateOptionSetRequest
Inherits OrganizationRequest
Inheritance
UpdateOptionSetRequest
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>
/// Updates the display name of a global choice.
/// </summary>
/// <param name="service">Authenticated IOrganizationService instance</param>
static void UpdateGlobalChoice(IOrganizationService service) {

      string choiceName = "channelaccessprofile_twitteraccess";
      string newLabelValue = "'X' Access";
      int languageCode = 1033; //English
      string solutionUniqueName = "BankAccount";

      RetrieveOptionSetRequest retrieveRequest = new()
      {
         Name = choiceName
      };

      var retrieveResponse = (RetrieveOptionSetResponse)service.Execute(retrieveRequest);

      // Just changing the Display Name in this example
      retrieveResponse.OptionSetMetadata.DisplayName = new Label(newLabelValue, languageCode);

      UpdateOptionSetRequest request = new()
      {
         OptionSet = retrieveResponse.OptionSetMetadata,
         MergeLabels = true,
         SolutionUniqueName = solutionUniqueName, 
      };

      // Send the request
      service.Execute(request);

      //Publish the OptionSet
      PublishXmlRequest publishRequest = new()
      {
         ParameterXml = $@"<importexportxml>
<optionsets>
<optionset>{{choiceName}}</optionset>
</optionsets>
</importexportxml>"
      };
      service.Execute(publishRequest);
}

Sample code on GitHub

Work with choice columns

Remarks

Usage

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

Privileges and Access Rights

To perform this action, the caller must have System administrator or System customizer security roles.

Notes for Callers

Use this message to update the basic information of global choice. Use these classes to change the options within the global choice:

For model-driven apps, you must publish the changes before they will be visible in the application. For more information, see Publish customizations.

Constructors

UpdateOptionSetRequest()

Initializes a new instance of the UpdateOptionSetRequest 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 Parameters collection.

(Inherited from OrganizationRequest)
MergeLabels

Gets or sets whether the label metadata will be merged or overwritten. Required.

OptionSet

Gets or sets the metadata for 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 a solution to associate the global choice with. Optional.

Applies to