Muokkaa

Jaa


Retrieve, update, and delete tables

Learn how to retrieve, update, and delete a table definition. This article uses the custom Bank Account table that was created in Create a custom table.

Retrieve and update a table

The following code sample retrieves a table definition by using the RetrieveEntityRequest message. It then updates the table to disable mail merge by setting the IsMailMergeEnabled property to false, and sets HasNotes to true in the UpdateEntityRequest to specify that the table should include a relationship to the Annotation table for the purpose of displaying notes.


RetrieveEntityRequest retrieveBankAccountEntityRequest = new RetrieveEntityRequest
{
 EntityFilters = EntityFilters.Entity,
 LogicalName = _customEntityName
};
RetrieveEntityResponse retrieveBankAccountEntityResponse = (RetrieveEntityResponse)_serviceProxy.Execute(retrieveBankAccountEntityRequest);
EntityMetadata BankAccountEntity = retrieveBankAccountEntityResponse.EntityMetadata;

// Disable Mail merge
BankAccountEntity.IsMailMergeEnabled = new BooleanManagedProperty(false);
// Enable Notes
UpdateEntityRequest updateBankAccountRequest = new UpdateEntityRequest
{
 Entity = BankAccountEntity,
 HasNotes = true
};

_serviceProxy.Execute(updateBankAccountRequest);

Delete a custom table

The following code sample uses the DeleteEntityRequest message to delete the table definition with the logical name specified by the _customEntityName variable.


DeleteEntityRequest request = new DeleteEntityRequest()
{
 LogicalName = _customEntityName,
};
_serviceProxy.Execute(request);

See also

Customize table definitions
Create and update a table to send email activities to rows
Create a custom table