0
我正在嘗試開發一個應用程序以允許通過gridview更新我們的CRM數據庫。從C更新CRM查找字段#
我所擁有的一切都在努力,直到試圖更新查找字段。試圖查找字段添加到更新它給了我一個錯誤,當
_service = GlobalFunctions.GetServiceAccount();
GlobalFunctions.User u = (GlobalFunctions.User)Session["UserInfo"];
Entity aspiration = new Entity("tog_aspiration");
aspiration.Id = new Guid(inputGridView.DataKeys[e.RowIndex].Value.ToString());
aspiration["tog_nofollrl"] = Int32.Parse(tog_nofollrl);
_service.Update(aspiration);
現在:
以下是工作的C#代碼。
_service = GlobalFunctions.GetServiceAccount();
GlobalFunctions.User u = (GlobalFunctions.User)Session["UserInfo"];
Entity aspiration = new Entity("tog_aspiration");
aspiration.Id = new Guid(inputGridView.DataKeys[e.RowIndex].Value.ToString());
aspiration["tog_nofollrl"] = Int32.Parse(tog_nofollrl);
aspiration["tog_techidname"] = new EntityReference("equipment", new Guid(ddlVet.SelectedValue));
_service.Update(aspiration);
以下是錯誤
Incorrect attribute value type System.String
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Incorrect attribute value type System.String
我只是去嘗試,它與同樣的錯誤失敗。我不是100%確定「設備」是正確的。 EntityReference()的參數應該是什麼? – MMoore94
也是「tog_techidname」是數據庫中的列名稱。我查看了數據庫中的設備視圖,它包含設備名稱和名稱。它不包含equipmentidname。 – MMoore94
CRM實體中字段的名稱是什麼? EntityReference應該是一對實體的LogicalName和一個Guid,沒有別的。 – Jordi