0
我用下面的代碼,試圖從Silverlight應用程序更新我的CRM系統2011查找字段的值:從Silverlight應用程序更新查找字段 - CRM 2011
try
{
ma.my_ActionDetails = details;
Guid userId = new Guid();
foreach (SystemUser s in SystemUsers)
{
if (s.FullName.Equals(comboBox1.SelectedItem))
{
userId = s.SystemUserId;
}
}
// Define eval statements for setting lookup to a value and null
string setLookupJscript = @"Xrm.Page.getAttribute(""{0}"").setValue([ {{ id: ""{1:B}"", typename: ""{2}"", name: ""{3}"" }}])";
string evalStatement = null;
// Set the statement to be evaluated based upon the value of the id argument
// Setting the lookup to a value
evalStatement = string.Format(setLookupJscript, "my_salesperson", userId, "my_memberaction", ma.my_SalesPerson.Name);
HtmlPage.Window.Eval(evalStatement);
_context.UpdateObject(ma);
_context.BeginSaveChanges(OnUpdateAccountComplete, ma);
}
catch (SystemException se)
{
_syncContext.Send(new SendOrPostCallback(showErrorDetails), se);
}
然而,當我運行此代碼會生成以下錯誤:
在瀏覽器:
'Xrm' is undefined
從代碼:
System.InvalidOperationException: [Common_MethodFailed]
任何人都可以解釋這是怎麼回事嗎?
感謝,
傑克