Compartir a través de


InsertStatusValueRequest Class

Definition

Contains the data that is needed to insert a new option into a StatusAttributeMetadata column.

public ref class InsertStatusValueRequest sealed : Microsoft::Xrm::Sdk::OrganizationRequest
[System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/xrm/2011/Contracts")]
public sealed class InsertStatusValueRequest : Microsoft.Xrm.Sdk.OrganizationRequest
[<System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/xrm/2011/Contracts")>]
type InsertStatusValueRequest = class
    inherit OrganizationRequest
Public NotInheritable Class InsertStatusValueRequest
Inherits OrganizationRequest
Inheritance
InsertStatusValueRequest
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 adding a new status option value
/// </summary>
/// <param name="service">Authenticated IOrganizationService instance</param>
static void InsertStatusValueExample(IOrganizationService service)
{

      int languageCode = 1033; //English
      string solutionUniqueName = "SolutionName";
      string tableLogicalName = "account";
      string columnLogicalName = "statuscode";
      string labelText = "Pending";
      string optionDescriptionLabel = "Not fully active";

      // Create a request.
      InsertStatusValueRequest request = new()
      {
         AttributeLogicalName = columnLogicalName,
         EntityLogicalName = tableLogicalName,
         Label = new Label(labelText, languageCode),
         Description = new Label(optionDescriptionLabel, languageCode),
         SolutionUniqueName = solutionUniqueName, 
         StateCode = 0 //Active
         // Value = 3, Recommend to let system set value
      };

      // Send the request:
      var response = (InsertStatusValueResponse)service.Execute(request);

      Console.WriteLine($"The new status option value is {response.NewOptionValue}".);
}

Output:

The new status option value is 152960000.

Sample code on GitHub

Work with choice columns

Remarks

For the Web API use the InsertStatusValue action.

Usage

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

Privileges and Access Rights

To perform this action, the caller must have the prvWriteOptionSet privilege included with the System administrator and System customizer security roles.

Constructors

InsertStatusValueRequest()

Initializes a new instance of the InsertStatusValueRequest class.

Properties

AttributeLogicalName

Gets or sets the logical name of the status column. Required.

Description

Gets or sets a description for the status option. Optional.

EntityLogicalName

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

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

Gets or sets the label for the new status option. Required.

OptionSetName

Reserved for future use. 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 that this status option should be added to. Optional.

StateCode

Gets or sets the state code for the new status option. Required.

Value

Gets or sets the value for the new status option. Optional.

Applies to