Search code examples
web-servicesdynamics-crm-4

Merge Account Detail Using CRM 4.0 Webservice if account exist


Need advise I am currently using CRM4.0 webservice to create account from reading my staging table which stored new account informations. I know there is a Create Duplicate Optional Parameter(false) which help to validate existing records. I need to check is there is also a function to merge the existing account with the new account enter?

If had do you guys have any sample or reference that i could use.Thanks Guys and ladies, I have been googling all afternoon and found no articles.

Thanks Brandon


Solution

  • You have to send a Merge Message which could be issued with an MergeRequest

    See following example which is included in the SDK

    // Create the target for the request.
    TargetMergeAccount target = new TargetMergeAccount();
    // EntityId is the GUID of the account that is being merged into.
    target.EntityId = new Guid("2B951FBC-1C56-4430-B23B-20A1349068F3");
    
    // Create the request.
    MergeRequest merge = new MergeRequest();
    // SubordinateId is the GUID of the account merging.
    merge.SubordinateId = new Guid("AD618DB2-F0DB-4A6A-8C4B-2F2213EAA38E");
    merge.Target = target;
    merge.PerformParentingChecks = false;
    
    account updateContent = new account();
    updateContent.address1_line1 = "test";
    merge.UpdateContent = updateContent;
    
    // Execute the request.
    MergeResponse merged = (MergeResponse)service.Execute(merge);