Handling of record OwnerId.
Table of Contents
- Overview
- Basic Example: OwnerId Assignment
- Advanced Example: Overriding the Default External ID for the User sObject
- Filtering User Records
- Support of Group sObject
Overview ⇧
Purpose: This feature allows the assignment and reassignment of the OwnerId
lookup values of the target records during data migration tasks.
Basic Example: OwnerId Assignment ⇧
To ensure that OwnerId
is correctly maintained when inserting records, include OwnerId
in your query string. Below is an example configuration that inserts Cases related to a specific Account while maintaining the correct OwnerId
on the target:
{
"objects": [
{
"operation": "Insert",
"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'"
}
]
}
Notes:
Ensure corresponding User and Group records exist in both the source and target organizations, as the default external ID for User objects is
Name
.User and Group records are combined into a unified record set within the utility, treating both groups and users as User objects.
Default queries for User and Group objects are simple ID selections, suitable for updating OwnerIds:
SELECT Id FROM User SELECT Id FROM Group WHERE Type = 'Queue'
Advanced Example: Overriding the Default External ID for the User sObject ⇧
It is possible to customize the external ID used for User objects. For example, to use ExternalId__c
instead of the default setting:
{
"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": "ExternalId__c",
"query": "SELECT Id FROM User"
}
]
}
Notes:
- Setting a custom external ID for users will apply the same field as the external ID for groups. Ensure this field exists in both User and Group object metadata.
- When overriding the User object's query, include only fields common to both User and Group objects, typically the Id field suffices.
Filtering User Records ⇧
In cases where an organization has many users, it may be necessary to filter which users are queried to manage performance and relevance. You can add custom WHERE
clauses to the User object's query to refine the selection:
{
"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'"
},
{
"query": "SELECT Id FROM User WHERE UserType = 'Standard'"
}
]
}
Support of Group sObject ⇧
Explicit configuration of Group objects is not supported in scripts.
Attempting to configure a group will result in it being automatically marked as excluded, with group management handled by the utility as described.