我需要檢索的全名和Dynamics CRM中接觸的上級單位。 我使用下面的代碼:獲取動態CRM接觸parentcustomerid
ColumnSet cols = new ColumnSet(new String[] { "fullname", "parentcustomerid" });
Entity retrContact = (Entity)orgService.Retrieve("contact", contactID, cols);
fullName = retrContact.Attributes["fullname"];
parentAccount = retrContact.Attributes["parentcustomerid"];
nameStr = fullName.ToString();
companyStr = parentAccount.ToString();
我的問題是companyStr獲得「Microsoft.Xrm.Sdk.EntityReference」,而不是名稱值。 parentAccount包含以下內容:
LogicalName "account" string
Name "Microsoft Corp" string
RowVersion null string
如何獲取Name字符串?
你已經有答案了。 companyStr是一個EntityReference,您可以簡單地使用companyStr.Name來獲取名稱。 – Renjith
companyStr是一個字符串,那麼請將.Name不存在那裏。我想知道爲什麼我不能使用parentAccount.Name。我得到錯誤:\t \t parentAccount.Name \t錯誤CS1061:'對象'不包含'名稱'的定義並且沒有擴展方法'名稱'接受類型'對象'的第一個參數可以找到(你是否缺少一個使用指令或程序集引用?) –