2012-10-16 26 views
2

在試圖合併Microsoft CRM聯繫人,我使用下面的代碼 -不能指定孩子在columnset屬性檢索

//c1ID and c2ID are GUIDs of duplicated contacts. 

EntityReference target = new EntityReference(); 
target.LogicalName = Contact.EntityLogicalName; 

target.Id = c2ID; 

MergeRequest merge = new MergeRequest(); 
// SubordinateId is the GUID of the account merging. 

merge.SubordinateId = c1ID; 
merge.Target = target; 
merge.PerformParentingChecks = true; 

Contact updater = new Contact(); 
Contact updater2 = new Contact(); 

updater = (Contact)xrmSvc.ContactSet.Where(c => c.ContactId.Equals(c1ID)).First(); 
updater2 = (Contact)xrmSvc.ContactSet.Where(c => c.ContactId.Equals(c2ID)).First(); 

MergeResponse mergedR = (MergeResponse)xrmSvc.Execute(merge); 

當我嘗試在這裏我執行電話,我得到這個錯誤 -

無法在檢索列集中指定子屬性。屬性:owneridname。

我不能設置正確的東西?

+0

請在你的方法中包括缺少的代碼。錯誤當然存在。 –

+0

@PeterMajeed - 增加了更多的代碼。 – duckmike

+0

'updater' /'updater2'行後面是什麼?我懷疑他們在'Merge'請求中使用,因爲他們沒有用於你的代碼片段中的其他任何東西。 –

回答

1

我希望我有這方面的一些文件,但雖然official documentation指出UpdateContent是可選的,但經驗證明它實際上是必要的。在我測試過的MergeRequest中,我總是在請求中包含該屬性,Dynamics 3.0的a post in the MSDN forums也暗示了相同。

事實上,當我嘗試合併在我組織的兩個觸點沒有UpdateContent分配,我居然得到了FaultException說以下內容:

必填字段「UpdateContent」缺少

儘管文檔說它是可選的!

所以我建議填充UpdateContent性質的東西在下面,看看是否可行:

var merge = new MergeRequest 
{ 
    // SubordinateId is the GUID of the account merging. 

    SubordinateId = c1ID, 
    Target = target, 
    PerformParentingChecks = true, 
    UpdateContent = new Contact() 
}; 
3

updatecontent不會改變的問題。實際上,我在updatecontent中輸入了查找錯誤。我發現你必須建立新的entityreferences:

if (match.Contains("new_mostrecentcampaign")) 
    master["new_mostrecentcampaign"] = 
     new EntityReference(match.GetAttributeValue<EntityReference>("new_mostrecentcampaign").LogicalName 
          , match.GetAttributeValue<EntityReference>("new_mostrecentcampaign").Id); 
... 
    Merge.UpdateContent = master 
...