2
我有一個HTML表單,它向使用SOAP Web服務連接到CRM的aspx頁面發佈信息。該頁面後面的代碼在CRM中創建一個實體。我在後面的代碼中使用IOrganizationService。創建一個字段爲optionset的新實體
代碼看起來像
IOrganizationService service = (IOrganizationService)serviceProxy;
Entity lead = new Entity("lead");
string fieldValue = string.Empty;
foreach (string key in Request.Form.AllKeys)
{
if (key.Equals(SubmitKey, StringComparison.InvariantCultureIgnoreCase) == false &&
key.Equals(CRMHostKey, StringComparison.InvariantCultureIgnoreCase) == false &&
key.Equals(redirectErrorURLKey, StringComparison.InvariantCultureIgnoreCase) == false &&
key.Equals(redirectSuccessURLKey, StringComparison.InvariantCultureIgnoreCase) == false)
{
if (!string.IsNullOrEmpty(Request.Form[key]))
{
fieldValue = Request.Form[key].Trim();
}
else
{
fieldValue = string.Empty;
}
if (key.Equals("new_contacttypechoices", StringComparison.InvariantCultureIgnoreCase))
{
lead[key] = new KeyValuePair<string, int>("Email", 100000000);
//OptionMetadata objOM = GetOptionMetadata("lead", "new_contacttypechoices", fieldValue, service);
//lead[key] = objOM;
//lead[key] = 100000000; //Incorrect attribute value type System.Int32
//lead[key] = fieldValue; //Incorrect attribute value type System.String
}
else
{
lead[key] = fieldValue;
}
}
newLeadID = service.Create(lead);
}
截圖領域的
我得到一個錯誤,當我嘗試
lead[key] = fieldValue
我得到一個錯誤,當我嘗試
lead[key] = 100000000
我得到一個錯誤,當我嘗試
lead[key] = new KeyValuePair<string, int>("Email", 100000000);
我得到一個錯誤,當我得到了OptionMetaData並將其設置爲實體。有關如何使用選項集創建實體的任何想法?
感謝
你會得到什麼錯誤? – glosrob
糟糕 - 我的apols,剛剛注意到內嵌評論 – glosrob