擷取、更新和刪除實體
發佈日期: 2017年1月
適用對象: Dynamics 365 (online)、Dynamics 365 (on-premises)、Dynamics CRM 2016、Dynamics CRM Online
本主題將說明如何使用 建立自訂實體 中建立的自訂 Bank Account 實體來擷取、更新和刪除實體。
本主題內容
擷取和更新實體
刪除自訂實體
擷取和更新實體
下列範例將使用 RetrieveEntityRequest 訊息擷取實體。 接著會藉由將 IsMailMergeEnabled 屬性設為 false 更新實體來停用合併列印,並且在 UpdateEntityRequest 將 HasNotes 設定為 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 程式碼
自訂實體中繼資料
建立和更新可郵寄實體
建立自訂實體
Microsoft Dynamics 365
© 2017 Microsoft. 著作權所有,並保留一切權利。 著作權