3

First question, with my ETL software, I could map all GM contact fields and migrate them to MCRM contact entity. The only field I can't is the owner (the owner is then always the creator of the contact).

I found that they are privileges on this entity fields prvAssignContact.

Is their a trick to remove this security, or a thing I could do through the SDK Toolkit I just started to use yesterday?

On SO, I found this topic, Can I update the owner id of a Contact using LINQ? but simply don't know if it will be useful for me and if yes, where to put that code.

P:S: I definitely have to do it alone... so I would enjoy user-friendly advices!

Community
  • 1
  • 1
Sébastien
  • 95
  • 6

2 Answers2

5

Will be useful to know which ETL you are using, however there is an important thing to consider when you do data migration. If you are creating a new record, to specify the owner is enough to set the field with an EntityReference

        Entity contact = new Entity("contact");
        contact["firstname"] = "John";
        Guid ownerId = new Guid("BFC777ED-5E79-E111-8489-00166D63156F");
        contact["ownerid"] = new EntityReference("systemuser", ownerId);
        service.Create(contact);

If you are updating a contact you need to use the AssignRequest as explained in the other topic

        Guid contactId = new Guid("90F8889F-EB95-E781-8417-000C44420CBC");
        Guid newOwnerId = new Guid("BFCAA4ED-5E79-E781-8349-00155BB3156F");
        AssignRequest assignRequest = new AssignRequest
        {
            Assignee = new EntityReference("systemuser", newOwnerId),
            Target = new EntityReference("contact", contactId)
        };
        service.Execute(assignRequest);
Pedro Azevedo
  • 2,507
  • 1
  • 16
  • 22
Guido Preite
  • 14,905
  • 4
  • 36
  • 65
  • hello, I am using StarFish ETL, I can use C # or vbscript to make a function field on the owner, thanks if you could bring me some details! – Sébastien Apr 03 '13 at 12:52
0

In addition to Guido's answer, if you use impersonation on your IOrganizationService, it will automatically set the owner to the impersonated user.

Daryl
  • 18,592
  • 9
  • 78
  • 145