DeleteOptionValueRequest Class

Definition

Contains the data that is needed to delete an option value in a global or local choice.

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

Delete a global choice option

/// <summary>
/// Demonstrates how to delete a global choice option
/// </summary>
/// <param name="service">Authenticated IOrganizationService instance</param>
/// <param name="value">The option value to remove</param>
/// <param name="globalChoiceName">The name of the global choice</param>
/// <param name="solutionUniqueName">The name of the solution to apply the change to</param>
static void DeleteGlobalChoiceValue(IOrganizationService service,
    int value,
    string globalChoiceName,
    string? solutionUniqueName
    )
{
    DeleteOptionValueRequest request = new()
    {
        Value = value,
        OptionSetName = globalChoiceName,
        SolutionUniqueName = solutionUniqueName
    };

    service.Execute(request);
}

Using this DeleteGlobalChoiceValue method:

DeleteGlobalChoiceValue(service, 152960002, "sample_test", "SolutionName");

Delete a local choice option

/// <summary>
/// Demonstrates how to delete a local choice option
/// </summary>
/// <param name="service">Authenticated IOrganizationService instance</param>
/// <param name="value">The option value to remove</param>
/// <param name="tableLogicalName">The logical name of the table that has the choice column.</param>
/// <param name="columnLogicalName">The logical name of the choice column</param>
/// <param name="solutionUniqueName">The name of the solution to apply the change to</param>
static void DeleteLocalChoiceValue(IOrganizationService service,
    int value,
    string tableLogicalName,
    string columnLogicalName,
    string? solutionUniqueName
    )
{
    DeleteOptionValueRequest request = new()
    {
        Value = value,
        EntityLogicalName = tableLogicalName,
        AttributeLogicalName = columnLogicalName,
        SolutionUniqueName = solutionUniqueName
    };

    service.Execute(request);
}        

Using this DeleteLocalChoiceValue method:

DeleteLocalChoiceValue(service, 152960002, "account", "sample_test", "SolutionName");

Sample code on GitHub

Work with choice columns

Remarks

For the Web API use the DeleteOptionValue action.

Usage

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

Privileges and Access Rights

To perform this action, the caller must have privileges included in the System Administrator or System Customizer security roles.

Notes for Callers

Use the OptionSetName property when working with global choices. For local option sets in a choice column, use the EntityLogicalName and AttributeLogicalName properties.

Constructors

DeleteOptionValueRequest()

Initializes a new instance of the DeleteOptionValueRequest class

Properties

AttributeLogicalName

Gets or sets the logical name of the choice column from which to delete the option value. Optional.

EntityLogicalName

Gets or sets the logical name of the table that contains the column. Optional.

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)
OptionSetName

Gets or sets the name of the global choice that contains the value. 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)
SolutionUniqueName

Gets or sets the solution name associated with this option value. Optional.

Value

Gets or sets the value of the option to delete. Required.

Applies to