閱讀英文版本

分享方式:


擷取、更新和刪除實體

 

發佈日期: 2016年11月

適用對象: Dynamics CRM 2015

本主題將說明如何使用 建立自訂實體 中建立的自訂 Bank Account 實體來擷取、更新和刪除實體。

本主題內容

擷取和更新實體

刪除自訂實體

擷取和更新實體

下列範例將使用 RetrieveEntityRequest 訊息擷取實體。 接著會藉由將 IsMailMergeEnabled 屬性設為 false 更新實體來停用合併列印,並且在 UpdateEntityRequestHasNotes 設定為 true,指定實體應該包含與 Annotation 實體的關聯,如此實體才能顯示附註。



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


Dim retrieveBankAccountEntityRequest As RetrieveEntityRequest = New RetrieveEntityRequest With {
 .EntityFilters = EntityFilters.Entity,
 .LogicalName = _customEntityName
}
Dim retrieveBankAccountEntityResponse As RetrieveEntityResponse = CType(_serviceProxy.Execute(retrieveBankAccountEntityRequest), RetrieveEntityResponse)
Dim BankAccountEntity As EntityMetadata = retrieveBankAccountEntityResponse.EntityMetadata

' Disable Mail merge
BankAccountEntity.IsMailMergeEnabled = New BooleanManagedProperty(False)
' Enable Notes
Dim updateBankAccountRequest As UpdateEntityRequest = New UpdateEntityRequest With {
 .Entity = BankAccountEntity,
 .HasNotes = True
}
_serviceProxy.Execute(updateBankAccountRequest)

刪除自訂實體

下列範例將使用 DeleteEntityRequest 訊息刪除採用 _customEntityName 變數所指定邏輯名稱的實體。


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

Dim request As New DeleteEntityRequest() With {.LogicalName = _customEntityName}
_serviceProxy.Execute(request)

另請參閱

使用範例和 Helper 程式碼
自訂實體中繼資料
建立和更新可郵寄實體
建立自訂實體

© 2017 Microsoft. 著作權所有,並保留一切權利。 著作權