【发布时间】:2010-06-10 17:07:24
【问题描述】:
我正在尝试使用 InitializeFromRequest 使用以下代码将 order 和 orderdetail 行转换为自定义实体及其子行:
public void Convert(Guid FromEntityId, string FromEntityName, string ToEntityName)
{
try
{
// Set up the CRM Service.
CrmService _service = GetCrmService();
InitializeFromRequest req = new InitializeFromRequest();
req.EntityMoniker = new Moniker(); // this is the very thing that does the job.
req.EntityMoniker.Id = FromEntityId;
req.EntityMoniker.Name = FromEntityName;
req.TargetEntityName = ToEntityName; //contact for our example req.
req.TargetFieldType = TargetFieldType.ValidForCreate;
InitializeFromResponse rps = (InitializeFromResponse)_service.Execute(req);
//now the lead is converted to a contact, and you can see it in contacts.
Guid entityId = _service.Create(rps.Entity);
lblMsg.Text = "Done ID:" + entityId.ToString();
}
catch (System.Web.Services.Protocols.SoapException se)
{
lblMsg.Text = "soap:" + se.Detail.InnerText;
}
catch (Exception ex)
{
lblMsg.Text = ex.Message;
}
}
现在我可以创建一个自定义实体,但所有属性都是空的,尽管我在 realtionship 中设置了映射字段。
我错过了什么或做错了什么?
【问题讨论】:
标签: c# dynamics-crm dynamics-crm-4