-
Notifications
You must be signed in to change notification settings - Fork 11
Config
Alex Bance edited this page Jun 28, 2021
·
7 revisions
-
Defines details of the entities and attributes that are to be extracted.
XML document defining the entities and attributes that are extracted from the CRM Instance. This schema can be constructed using the Configuration Migration tool in the XRM SDK. The easiest way to download the latest SDK is to get it from xrm.tools
Export config file is used by the engine to configure different processors which together build the final output. It can be constructed directly in code:
var exportConfig = new CrmExporterConfig()
{
BatchSize = 1000,
PageSize = 500,
FilePrefix = "Prefix",
OneEntityPerBatch = true,
SeperateFilesPerEntity = true,
TopCount = 10000,
CrmMigrationToolSchemaFilters = new Dictionary<string, string> {
{"team", "<filter> <condition attribute=\"name\" operator=\"neq\" value=\"capgeminitest\" /> </filter>" },
{"businessunit","<filter> <condition attribute=\"parentbusinessunitid\" operator=\"not-null\" /> </filter>"}
},
JsonFolderPath = "ExportPath",
CrmMigrationToolSchemaPaths = new List<string> { "Schema path" },
ExcludedFields = new List<string> { "ownerid", "createddate" },
LookupMapping = new Dictionary<string, Dictionary<string, List<string>>> {
{"businessunit", new Dictionary<string, List<string>> {
{ "businessunitid", new List<string> { "name" }}}
},
{"team", new Dictionary<string, List<string>> {
{ "teamid", new List<string> { "name", "businessunitid" }},
{ "businessunitid", new List<string> { "name" }}}
},
{"teamroles", new Dictionary<string, List<string>>
{
{"roleid", new List<string> { "name", "businessunitid"}},
{"teamid", new List<string> { "name", "businessunitid"}}
}}
},
OnlyActiveRecords = true
};
Or configuration can be loaded from Json file by using the following syntax:
var exportConfig = CrmExporterConfig.GetConfiguration("file path");
Json file format for the above code will be:
{
"ExcludedFields": [
"ownerid",
"createddate"
],
"CrmMigrationToolSchemaPaths": [
"Schema path"
],
"CrmMigrationToolSchemaFilters": {
"team": "<filter> <condition attribute=\"name\" operator=\"neq\" value=\"capgeminitest\" /> </filter>",
"businessunit": "<filter> <condition attribute=\"parentbusinessunitid\" operator=\"not-null\" /> </filter>"
},
"PageSize": 500,
"BatchSize": 1000,
"TopCount": 10000,
"OnlyActiveRecords": true,
"JsonFolderPath": "ExportPath",
"OneEntityPerBatch": true,
"FilePrefix": "Prefix",
"SeperateFilesPerEntity": true,
"LookupMapping": {
"businessunit": {
"businessunitid": [
"name"
]
},
"team": {
"teamid": [
"name",
"businessunitid"
],
"businessunitid": [
"name"
]
},
"teamroles": {
"roleid": [
"name",
"businessunitid"
],
"teamid": [
"name",
"businessunitid"
]
}
}
}
Config Key | Description |
---|---|
ExcludedFields | Names of fields which will be excluded from data query for all entities, usually used for some system fields when the full schema is generated. |
FetchXMLFolderPath | Optional path to folder with FetchXml xml files containing queries to retrieve data. Combinations of FetchXml and Schema can be used to define the full export list. This used in connection with CrmMigrationToolSchemaPaths and CrmMigrationToolSchemaFilters |
CrmMigrationToolSchemaPaths | Path to the schema file, multiple schema files are supported |
CrmMigrationToolSchemaFilters | Fetch XML filters for exported entities |
PageSize | Defines the number of records to be read in a single page. |
BatchSize | Defines the number of records each export file can contain. |
TopCount | Upper limit on the number of records that are exported. |
OnlyActiveRecords | Restricts the export based on records status. |
JsonFolderPath | Defines the folder that holds the exported files. |
OneEntityPerBatch | Only applies of SeperateFilesPerEntity is false. If this is false then Export files are created upto the BatchSize value containing data from one or more entities. |
FilePrefix | Defines the common prefix for all exported files |
SeperateFilesPerEntity | Ensures that each entity type will be saved to a seperate file, otherwise there might be multiple entities types in one file basedon the setting of OneEntityPerBatch. |
LookupMapping | Adds additional data to exported files which during the import process is used to find existing records in the system to reconstruct references. Supports complex keys composed from multiple columns |
Import config file is used by the engine to configure different processors which together controls the import process. It can be constructed directly in code:
var importConfig = new CrmImportConfig()
{
FilePrefix = "Prefix",
SaveBatchSize = 50,
JsonFolderPath = "ExportPath",
AdditionalFieldsToIgnore = new List<string> { "name", "owner" },
DeactivateAllProcesses = false,
EntitiesToSync = new List<string> { "contact", "list" },
IgnoreStatuses = true,
IgnoreStatusesExceptions = new List<string> { "knowledgearticle", "contact" },
IgnoreSystemFields = true,
MigrationConfig = new MappingConfiguration
{
ApplyAliasMapping = true,
SourceRootBUName = "test",
Mappings = new Dictionary<string, Dictionary<Guid, Guid>> {
{ "contact" , new Dictionary<Guid, Guid> {
{ Guid.NewGuid(), Guid.NewGuid() },
{ Guid.NewGuid(), Guid.NewGuid() }}
},
{ "businessunit" , new Dictionary<Guid, Guid> {
{ Guid.NewGuid(), Guid.NewGuid() },
{ Guid.NewGuid(), Guid.NewGuid() },
{ Guid.NewGuid(), Guid.NewGuid() }}
},
}
},
NoUpsertEntities = new List<string> { "list", "contact" },
PassOneReferences = new List<string> { "queue", "businessunit" },
PluginsToDeactivate = new List<Tuple<string, string>> {
new Tuple<string, string>("Plugin.dll", "Plugin 1"),
new Tuple<string, string>("Plugin.dll", "Plugin 2")
},
ProcessesToDeactivate = new List<string>() { "Process 1", "Process 2" },
NoUpdateEntities = new List<string> { "account" },
};
Or configuration can be loaded from Json file by using the following syntax:
importConfig = CrmImportConfig.GetConfiguration("file path");
Json file format for the above code will be:
{
"IgnoreStatuses": true,
"IgnoreStatusesExceptions": [
"knowledgearticle",
"contact"
],
"IgnoreSystemFields": true,
"MigrationConfig": {
"ApplyAliasMapping": true,
"Mappings": {
"contact": {
"35ff0e64-263b-4228-82ef-4ad175e5e9ab": "fcd52a37-be2f-4d30-86b7-bd34898190a7",
"549403df-4984-4b80-9f59-424dbf7f7d89": "a96feb53-ec11-4cce-be33-150324fe11c4"
},
"businessunit": {
"10d7e458-575c-4c53-9df4-01c3c030f604": "c4ecc4b7-abc1-4ea4-99a6-58e0055746f4",
"e54dbdf9-186c-4352-b85e-0325a8a5982d": "b5a0b165-9b98-4fde-a5d6-de242a7bbe0e",
"a273231a-6e6d-409f-ad92-53c8abe9d869": "c721e932-27af-40ed-8cb8-2fa8bfb48776"
}
},
"SourceRootBUName": "test"
},
"AdditionalFieldsToIgnore": [
"name",
"owner"
],
"SaveBatchSize": 50,
"JsonFolderPath": "ExportPath",
"EntitiesToSync": [
"contact",
"list"
],
"NoUpsertEntities": [
"list",
"contact"
],
"PluginsToDeactivate": [
{
"Item1": "Plugin.dll",
"Item2": "Plugin 1"
},
{
"Item1": "Plugin.dll",
"Item2": "Plugin 2"
}
],
"ProcessesToDeactivate": [
"Process 1",
"Process 2"
],
"DeactivateAllProcesses": false,
"FilePrefix": "Prefix",
"PassOneReferences": [
"queue",
"businessunit"
],
"NoUpdateEntities": [
"account",
],
}
Config Key | Description |
---|---|
IgnoreStatuses | No entity statuses are set up even if exist in exported files |
IgnoreStatusesExceptions | List of entites for which statuses will be updated even if IgnoreStatuses is True |
IgnoreSystemFields | Ignores system fields during import, even if exist in the exported files. System fields are ignored are: "createdby", "createdonbehalfby", "createdon", "importsequencenumber", "modifiedby", "modifiedonbehalfby", "modifiedon", "owneridtype", "owningbusinessunit", "owningteam", "owninguser", "overriddencreatedon", "timezoneruleversionnumber", "utcconversiontimezonecode", "versionnumber", "transactioncurrencyid", "organizationid" |
MigrationConfig.ApplyAliasMapping | Configures how the LookupMapping data included in the exported files are used during import. False - the values in Export files are not used, True - the values in Export files are used to find records first in the target system |
MigrationConfig.Mappings | Guid mappings are configured at the Entity level. If Guid is found in source file it will be replaced as configured prior to import to the target instance. |
MigrationConfig.SourceRootBUName | Defines Root Business Unit Name in the exported files. These are then replaced by the Root Business Unit Name in the target instance. |
AdditionalFieldsToIgnore | List of fields to be ignored for all entities even if they exist in the exported files |
SaveBatchSize | Batch size used for "ExecuteMultiple" request to save data to Dynamics 365 |
JsonFolderPath | Defines the folder that holds the exported files. |
EntitiesToSync | Enforces in the target system to have only entities included in the export files. Very risky seeting, use on your own risk, will delete records from Dynamics which don;t exist in files |
NoUpsertEntities | The Upsert request (in one call update or create) will not be used for the configured entities. When loading these entities the engine will try to update but if record does not exist it will do a create request. |
PluginsToDeactivate | List of plugins to deactivate before import, the Plugins deactivated will be automatically activated after import is finished |
ProcessesToDeactivate | List of processes (workflows) to to deactivate before import, the processes deactivated will be automatically activated after import is finsihed |
DeactivateAllProcesses | Deactivates all active plugins and workflows before import, ignoring the previous selective configuration, the plugins and processes deactivated will be automatically activated after import is finished |
FilePrefix | Defines the common prefix for all exported files |
PassOneReferences | Used by engine to define the list of entities (references) which will be created in one go, if empty then the default list is used: "businessunit", "uom", "uomschedule", "queue" |
NoUpdateEntities | List of entities where the engine will only ever create records, it will not update them. |