我有一个 html 表单,它发布到一个使用 SOAP Web 服务连接到 CRM 的 aspx 页面。页面背后的代码在 CRM 中创建了一个实体。我在后面的代码中使用 IOrganizationService。
代码看起来像
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 并将其设置为实体时出现错误。关于如何使用选项集创建实体的任何想法?
谢谢