Export (0) Print
Expand All

DeleteAttribute Message (MetadataService)

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Works for all deployment typesWorks online only

Deletes an attribute from an entity.

The relevant classes are specified in the following table.

TypeClass
RequestDeleteAttributeRequest
ResponseDeleteAttributeResponse

Remarks

To perform this action, the caller must be a user in the organization for which metadata is requested and must have the Delete Attribute, Read Organization UI, Read Saved Query, and Read Workflow privileges.

You cannot delete an attribute that is in use on a form or in a view or an attribute that is in use in a workflow.

Example

The following example shows how to use the DeleteAttribute 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 the request.
DeleteAttributeRequest deleteAttribute = new DeleteAttributeRequest();
deleteAttribute.LogicalName = "new_string_attribute";
deleteAttribute.EntityLogicalName = EntityName.contact.ToString();
   
// Execute the request.
DeleteAttributeResponse deleteResponse = (DeleteAttributeResponse)metadataService.Execute(deleteAttribute);
[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 deleteAttribute As New DeleteAttributeRequest()
deleteAttribute.LogicalName = "new_string_attribute"
deleteAttribute.EntityLogicalName = EntityName.contact.ToString()

' Execute the request.
Dim deleteResponse As DeleteAttributeResponse = CType(metadataService.Execute(deleteAttribute), DeleteAttributeResponse)

See Also

Concepts

Reference


© 2010 Microsoft Corporation. All rights reserved.


Show:
© 2014 Microsoft