MSCRM 4 Convert Standard entity to Custom entity using InitializeFromRequest

I'm trying to convert an order and orderdetail lines to a custom entity and its child lines using InitializeFromRequest using the code below:

public void Convert(Guid FromEntityId, string FromEntityName, string ToEntityName)
        // 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;

Now I am able to get a custom entity created but all the attributes are empty despite me setting the mapping fields in the realtionship.

What am I missing or doing wrong?


You need to set ReturnDynamicEntities = true when converting an standard entity to a custom one.

Need Your Help

installing java JDK 7 to run javafx - osx

java macos intellij-idea javafx

I have installed java JDK 7 in my osx. It is installed in /Library/Java/JavaVirtualMachines/ where are 1.6 java version is installed in /System/Library/Java/JavaVirtualMachines. Which is fine in my...