Handling of record OwnerId.


The SFDMU allows you to assign and to reassign OwnerId lookup value of the target records. 

In order to assign OwnerId to the records you have simply to add OwnerId to the query string.

Find below the sample configuration to Insert Cases related to the given Account record, while keeping proper OwnerId on the target side:

{
    "objects": [
        {
            "operation": "Insert",
            "externalId": "CaseNumber",
            "query": "SELECT Id, Origin, Subject, Status, AccountId, Type, Description, CaseNumber, OwnerId FROM Case",
            "master": false
        },
        {
              "operation": "Readonly",
            "externalId": "Name",
            "query": "SELECT Id FROM Account WHERE Name = 'ACC_10000'"
        }
    ]
}

Additional information:
  • The example of above shows Case insertions and the CaseNumber field is set as an the Case External ID.
    But if you want to Update the existing OwnerId lookup values, you should define other unique field raither than CaseNumber as an External ID, since CaseNumber is of auto-number type and such setting External ID to auto-number field does not allow record update.

  • Make sure that you have the User and Group records with the same Names both in the Source and the Target orgs, because the default External ID for User object is set to Name.

  • You have also option to override the default External ID setting of the User object, e.g. set it to Username:

    {
        "objects": [
            {
                "operation": "Insert",
                "externalId": "CaseNumber",
                "query": "SELECT Id, Origin, Subject, Status, AccountId, Type, Description, CaseNumber, OwnerId FROM Case",
                "master": false
            },
            {
                  "operation": "Readonly",
                "externalId": "Name",
                "query": "SELECT Id FROM Account WHERE Name = 'ACC_10000'"
            },
            {
                  "externalId": "Username", 	// This will set Username field instead of Name as an External ID for the User object.
                                             //This is technically possible but not recommended action. 
                                            //It's would be better to not override the default External ID (Name) for the User object.
                "query": "SELECT Id FROM User"
            }
        ]
    }
    

    Please consider the followings when overriding the default User's external Id:

    • The Plugin usually fetches all User and Group records from the remote and then internally joins these records in a union record set of User object. So finally all Groups and Users are finally considered by the Plugin as if they are Users.
    • If you change the default External ID of the User object to Username or other User's field, this will automatically set the External ID of Group to Username as well. But since there is no such field Username defined for Group, the Plugin will not be able to assign OwnerId correctly on the target side, when the source Case OwnerId is a Public Group.
    • Finally, even technically it's possible, we would not recommend you to change the default External Id key for User object to a different field than Name unless you are sure that all records are assigned to Users and none to Public Group. Unlike Username, the Name field is available both for User and for Group objects and can be treated well for both objects.
Last updated on 29th Jan 2023