Export (0) Print
Expand All

InsertStatusValue Message (MetadataService)

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Works for all deployment typesWorks online only

Adds a new status code to an entity's statuscode attribute. The relevant classes are specified in the following table.

TypeClass
RequestInsertStatusValueRequest
ResponseInsertStatusValueResponse

Remarks

To perform this action, the caller must be a user in the organization for which metadata is requested and must have Write Attribute privilege.

If a value property is provided and is not already in use, that value will be used as the new statuscode value. Otherwise, a new value property will be assigned and returned in the response.

You must publish the changes to the metadata before this change will be visible in the application. For more information see Publishing the Metadata.

Example

The following example shows how to use the InsertStatusValue message.

[C#]
// Create an authentication token.
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.OrganizationName = "AdventureWorksCycle";

// You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0; 

// Create the metadata Web service;
MetadataService metadataService = new MetadataService();
metadataService.Url = "http://<servername>:<port>/MSCRMServices/2007/MetadataService.asmx";
metadataService.CrmAuthenticationTokenValue = token;
metadataService.Credentials = System.Net.CredentialCache.DefaultCredentials;
metadataService.PreAuthenticate = true;

// Create a US English label
MetadataServiceSdk.LocLabel englishLabel = new MetadataServiceSdk.LocLabel();
englishLabel.LanguageCode = new MetadataServiceSdk.CrmNumber();
englishLabel.LanguageCode.Value = 1033;
englishLabel.Label = "New Status Label";


// Create the request.
InsertStatusValueRequest insertRequest = new InsertStatusValueRequest();

// Set the request properties
insertRequest.AttributeLogicalName = "statuscode";
insertRequest.EntityLogicalName = EntityName.contact.ToString();
insertRequest.Label = new MetadataServiceSdk.CrmLabel();
insertRequest.Label.LocLabels = new MetadataServiceSdk.LocLabel[] { englishLabel };
insertRequest.StateCode = new MetadataServiceSdk.CrmNumber();
insertRequest.StateCode.Value = 0;
insertRequest.Value = new MetadataServiceSdk.CrmNumber();

// New picklist values in Microsoft Dynamics CRM 4.0 start at 200,000 to maintain backward compatibility with Microsoft CRM 3.0
insertRequest.Value.Value = 200000;

// Execute the request
InsertStatusValueResponse insertResponse = (InsertStatusValueResponse)metadataService.Execute(insertRequest);
[Visual Basic .NET]
' Set up the CRM service.
Dim token As New CrmAuthenticationToken()
' You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0
token.OrganizationName = "AdventureWorksCycle";

// Create the metadata Web service.
Dim metadataService As New MetadataService ()
metadataService.Url = "http://<servername>:<port>/mscrmservices/2007/MetadataService.asmx";
metadataService.CrmAuthenticationTokenValue = token;
metadataService.Credentials = System.Net.CredentialCache.DefaultCredentials
metadataService.PreAuthenticate = true;

' Create the request.
Dim insertRequest As New InsertStatusValueRequest()

' Set the request properties.
insertRequest.AttributeLogicalName = "statuscode"
insertRequest.EntityLogicalName = EntityName.contact.ToString()
insertRequest.Label = New MetadataServiceSdk.CrmLabel()
insertRequest.Label.LocLabels = New MetadataServiceSdk.LocLabel() { englishLabel }
insertRequest.StateCode = New MetadataServiceSdk.CrmNumber()
insertRequest.StateCode.Value = 0
insertRequest.Value = New MetadataServiceSdk.CrmNumber()

' New picklist values in Microsoft Dynamics CRM 4.0 start at 200,000 to maintain backward compatibility with Microsoft Dynamics CRM 3.0.
insertRequest.Value.Value = 200000

' Execute the request.
Dim insertResponse As InsertStatusValueResponse = CType(metadataService.Execute(insertRequest), InsertStatusValueResponse)

See Also

Concepts

Reference


© 2010 Microsoft Corporation. All rights reserved.


Show:
© 2014 Microsoft