Migrating InCountry Metadata between Salesforce Orgs
You can migrate metadata and configuration of the InCountry Data Residency for Salesforce package from a source Salesforce org to a target Salesforce org.
Retrieving metadata and configuration from the source Salesforce org
Metadata of FlexiPages
You can retrieve metadata of the FlexiPages that reference InCountry components.
To retrieve metadata of all FlexiPages, use the following command:
sf project retrieve start --metadata FlexiPage
or specify names of FlexiPages:
sf project retrieve start --metadata FlexiPage:<Component Name>
Metadata of feature flags
You can retrieve metadata of feature flags and their actual values.
To retrieve metadata of all feature flags and their values, use the following command:
sf project retrieve start --metadata CustomMetadata
or specify the feature flag name:
sf project retrieve start --metadata CustomMetadata:<Flag or Value Name>
Metadata of data regulation policies
You can retrieve values of a specific data regulation policy. The output will be stored in the testIncountry1__Object_relationship__c.json
file in the current directory.
sf data export tree
--query "SELECT testInCountry1__Behavior__c,
testInCountry1__Country__c,
testInCountry1__Country_field__c,
testInCountry1__CountryFieldValue__c,
testInCountry1__Criteria__c,
testInCountry1__Object_name__c,
testInCountry1__Type__c,
FROM testInCountry1__Object_relationship__c"
Metadata of regulated fields
You can retrieve configuration of regulated fields. The output will be stored in the testIncountry1__Object_relationship_fields__c.json
file in the current directory.
sf data export tree
--query "SELECT Name, testIncountry1__Country__c, testIncountry1__Field_name__c,
testIncountry1__FixedValue__c, testIncountry1__Formula__c,
testIncountry1__HashFunction__c, testIncountry1__IsCompound__c,
testIncountry1__IsCountryField__c, testIncountry1__IsLookup__c,
testIncountry1__key__c, testIncountry1__LookupObjectApiName__c,
testIncountry1__LookupRelationshipName__c,
testIncountry1__LookupRequiredToSelectFields__c, testIncountry1__NeedHash__c,
testIncountry1__Object_name__c, testIncountry1__RawTokenizationFormula__c,
testIncountry1__Reference_field__c, testIncountry1__Reference_order__c,
testIncountry1__SearchKey__c, testIncountry1__TokenizationFormula__c,
testIncountry1__Validation_strategy__c
FROM testInCountry1__Object_relationship_fields__c"
Metadata of InCountry reports
You can retrieve metadata of InCountry reports by using the following SOQL queries with sf data export tree
or an equivalent command. Each output will be stored in a separate .json
or .csv
file.
// Retrieve Folders
SELECT testIncountry1__FolderId__c, Name, testIncountry1__isPrivate__c, testIncountry1__Label__c,
testIncountry1__Share_Request__c
FROM testIncountry1__Folder__c
// Retrieve Reports
SELECT Name, testIncountry1__Label__c, testIncountry1__Description__c, testIncountry1__FolderId__c,
testIncountry1__PrimaryObject__c
FROM testIncountry1__Report__c
// Retrieve Report Groups
SELECT Name, testIncountry1__Field__c, testIncountry1__ReportId__c
FROM testIncountry1__Group__c
// Retrieve Report Filters
SELECT Name, testIncountry1__Logic__c, testIncountry1__ReportId__c, testIncountry1__Scope__c
FROM testIncountry1__Filter__c
// Retrieve Report Filter Items
SELECT Name, testIncountry1__Field__c, testIncountry1__FilterId__c, testIncountry1__Operator__c, testIncountry1__Position__c, testIncountry1__Value__c
FROM testIncountry1__FilterItem__c
// Retrieve Report Columns
SELECT Name, testIncountry1__Field__c, testIncountry1__Order__c, testIncountry1__ReportId__c, testIncountry1__SortDirection__c, testIncountry1__SortOrder__c
FROM testIncountry1__Column__c
Metadata of list views
You can retrieve metadata of list view configurations by using the following SOQL queries with sf data export
or an equivalent command. Each output will be stored in a separate .json
or .csv
file.
// Retrieve List View Filters
SELECT Name, testIncountry1__Context__c, testIncountry1__Label__c,
testIncountry1__Logic__c, testIncountry1__Queue__c, testIncountry1__Scope__c
FROM testIncountry1__InCountryFilter__c
// Retrieve List View Filter Items
SELECT Name, testIncountry1__DataType__c, testIncountry1__FieldName__c,
testIncountry1__FieldValue__c, testIncountry1__FilterId__c,
testIncountry1__Label__c, testIncountry1__Operator__c
FROM testIncountry1__InCountryFilterItem__c
Resident functions
You can retrieve metadata of resident functions by using the following command:
sf data export tree
--query "SELECT Name, testIncountry1__Active__c, testIncountry1__AdditionalParameters__c,
testIncountry1__ApexHandler__c, testIncountry1__ObjectApiName__c,
testIncountry1__OperationType__c, testIncountry1__ServerlessName__c
FROM testIncountry1__InCountry_Trigger__c"
InCountry frontend validation
You can retrieve metadata of InCountry frontend validations by using the following command:
sf data export tree
--query "SELECT Name, testIncountry1__Active__c, testIncountry1__Description__c,
testIncountry1__ErrorConditionFormula__c, testIncountry1__ErrorLocation__c,
testIncountry1__ErrorLocationField__c, testIncountry1__ErrorMessage__c,
testIncountry1__ObjectApiName__c, testIncountry1__RuleName__c,
testIncountry1__SalesforceRuleId__c
FROM testIncountry1__ValidationRule__c"
Assignments of permission sets
You can retrieve permission set assignments by using the following command:
sf data export tree
--query "SELECT Id, AssigneeId, PermissionSetId
FROM PermissionSetAssignment
WHERE PermissionSet.Name LIKE 'InCountry%'"
Installing the package on the target organization
You can use the following Salesforce CLI command to install the specified package version id:
sf package install --package <version id>
Pushing metadata and configuration to the target Salesforce org
FlexiPages
Use the following commands to deploy the FlexiPages metadata:
1. metadata of all FlexiPages:
sf project deploy start --metadata FlexiPage
2. specific FlexiPages (reference specific names):
sf project deploy start --metadata FlexiPage FlexiPage:<Component Name>
Feature flags
Use the following commands to deploy feature flags and their values:
1. all feature flags and their values:
sf project deploy start --metadata CustomMetadata
2. specific feature flags (reference specific names):
sf project deploy start --metadata CustomMetadata:<Flag or Value Name>
Data regulation policies and regulated fields
Use the following command to deploy data regulation policies and regulated fields:
sf data import tree --files testIncountry1__Object_relationship__c.json, testIncountry1__Object_relationship_fields__c.json
InCountry reports
Use the sf data import tree
command to deploy InCountry reports with the following objects:
testIncountry1__Folder__c
testIncountry1__Report__c
testIncountry1__Group__c
testIncountry1__Filter__c
testIncountry1__FilterItem__c
testIncountry1__Column__c
List views
Use the sf data import tree
command to deploy list views and their configuration with the following objects:
testIncountry1__InCountryFilter__c
testIncountry1__InCountryFilterItem__c
Resident functions
Use the following command to deploy resident functions and their configuration:
sf data import tree --files testIncountry1__InCountry_Trigger__c.json
InCountry frontend validations
Use the following command to deploy frontend validations and their configuration:
sf data import tree --files testIncountry1__ValidationRule__c.json
Permission sets
Use the following command to deploy permission sets and their configuration:
sf data import tree --files PermissionSetAssignments.json
[Optional] Migrating authentication details
We do not recommend to migrate the authentication information from a source Salesforce org to a target org, but this is possible as well.
Remote Site settings
To migrate the Remote Site settings, use the following commands:
/*****************************
/ Retrieve Settings /
/****************************/
// For all Remote Site Settings
sf project retrieve start --metadata RemoteSiteSetting
// For specific Remote Site Settings
sf project retrieve start --metadata RemoteSiteSetting:<Setting Name>
/*****************************
/ Deploy Settings /
/****************************/
// For all Remote Site Settings
sf project deploy start --metadata RemoteSiteSetting
// For specific Remote Site Settings
sf project deploy start --metadata RemoteSiteSetting:<Setting Name>
Auth Providers
To migrate Auth Providers, use REST API to retrieve and deploy them:
{
"DeveloperName": "Auth_Provider",
"FriendlyName": "Auth Provider",
"AuthorizeUrl": "<Hydra URL>",
"ConsumerKey": "<Consumer Key>",
"ConsumerSecret": "<Consumer Secrets>",
"OptionsIncludeOrgIdInId": "true",
"ProviderType": "Custom",
"TokenUrl": "<Token URL>",
"CustomMetadataTypeRecord": "<MTD>",
"DefaultScopes": "<Scope>",
"ExecutionUserId": "<User Id>",
"PluginId": "<Apex Class Id>"
}
Named Credentials
To retrieve and deploy named credentials, the XML file should have the following structure:
<?xml version="1.0" encoding="UTF-8"?>
<NamedCredential xmlns="http://soap.sforce.com/2006/04/metadata">
<allowMergeFieldsInBody>false</allowMergeFieldsInBody>
<allowMergeFieldsInHeader>false</allowMergeFieldsInHeader>
<authProvider>Auth_Provider</authProvider>
<endpoint><InCountry Rest API endpoint></endpoint>
<generateAuthorizationHeader>true</generateAuthorizationHeader>
<label>Creds_Demo</label>
<principalType>NamedUser</principalType>
<protocol>Oauth</protocol>
</NamedCredential>