【问题标题】:MSCRM 4 Convert Standard entity to Custom entity using InitializeFromRequestMSCRM 4 使用 InitializeFromRequest 将标准实体转换为自定义实体
【发布时间】: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


    【解决方案1】:

    在将标准实体转换为自定义实体时,您需要设置 ReturnDynamicEntities = true。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-14
      • 1970-01-01
      • 2012-01-04
      • 2017-10-18
      • 2019-04-27
      • 1970-01-01
      • 2012-09-24
      • 2011-08-06
      相关资源
      最近更新 更多