organizationsetup - ServiceTransfer DataSets
DataSet Values: ServiceTransfer | ServiceTransferWithoutDomainRelationships
The ServiceTransfer DataSets copy service delivery configuration from a template environment to a target environment, including PRIMHD teams, contracts, services, eligibility rules, and the complete outcomes framework.
When to Use
Use the ServiceTransfer DataSet when:
✅ Setting up service delivery in new environment
✅ Migrating service configuration between environments
✅ Adding new contract services with eligibility rules
✅ Establishing complete service infrastructure including outcomes
✅ Synchronising service setup across environments
Use the ServiceTransferWithoutDomainRelationships variant when:
✅ All outcome relationships (domain-area AND area-category) already exist in target
✅ Want to skip ALL relationship table processing for performance
✅ Updating services without touching any outcome relationships
✅ Outcome framework structure is completely stable and doesn't need sync
Do not use when:
❌ You need complete environment setup (use All instead)
❌ You only need outcomes framework (use OutcomesFramework instead)
❌ You only need specific tables (use datamanipulation instead)
DataSet Comparison
| Feature | ServiceTransfer | ServiceTransferWithoutDomainRelationships |
|---|---|---|
| PRIMHD Teams | ✅ Yes | ✅ Yes |
| Contract Grouping | ✅ Yes | ✅ Yes |
| Funding Contract Types | ✅ Yes | ✅ Yes |
| Funding Contracts | ✅ Yes | ✅ Yes |
| Contract Services | ✅ Yes | ✅ Yes |
| Service Eligibility Rules | ✅ Yes | ✅ Yes |
| Contract Service Types | ✅ Yes | ✅ Yes |
| Contract Service Sites | ✅ Yes | ✅ Yes |
| Outcome Domains | ✅ Yes | ✅ Yes |
| Domain Indicators | ✅ Yes | ✅ Yes |
| Outcome Areas | ✅ Yes | ✅ Yes |
| Outcome Categories | ✅ Yes | ✅ Yes |
| Domain-Area Relationships | ✅ Yes | ❌ No |
| Area-Category Relationships | ✅ Yes | ❌ No |
| Activity Groups | ✅ Yes | ✅ Yes |
| Predefined Outcomes | ✅ Yes | ✅ Yes |
| Consent Types | ✅ Yes | ✅ Yes |
| Predefined Activities | ✅ Yes | ✅ Yes |
| Operation Count | 18 operations | 16 operations |
Key difference: The WithoutDomainRelationships variant skips creating both mag_mag_outcomearea_mag_domain (domain-area) and mag_mag_outcomecategory_mag_outcomearea (area-category) relationship records. All other operations are identical.
Command Syntax
ServiceTransfer (Full)
.\WhanauTahi.Xpm.Tooling.exe organizationsetup `
--MasterDataUrl "https://masterdata.crm6.dynamics.com" `
--EnvironmentUrl "https://target.crm6.dynamics.com" `
--ClientId "12345678-1234-1234-1234-123456789abc" `
--DataSet "ServiceTransfer"
ServiceTransferWithoutDomainRelationships (Optimised)
.\WhanauTahi.Xpm.Tooling.exe organizationsetup `
--MasterDataUrl "https://masterdata.crm6.dynamics.com" `
--EnvironmentUrl "https://target.crm6.dynamics.com" `
--ClientId "12345678-1234-1234-1234-123456789abc" `
--DataSet "ServiceTransferWithoutDomainRelationships"
How It Works
Operation Sequence - ServiceTransfer
The ServiceTransfer DataSet performs 18 operations in dependency order:
1. PRIMHD Configuration
└── PRIMHD teams
2. Contract Infrastructure - Types & Grouping
├── Funding contract types
├── Contract grouping (2-pass: create, then link parents)
├── Contract service types
└── Contract service sites
3. Contract Infrastructure - Contracts & Services
├── Funding contracts
├── Contract services
└── Service eligibility rules
4. Outcomes Framework - Foundation
├── Outcome domains
├── Domain indicators
├── Outcome areas
└── Outcome categories
5. Outcomes Framework - Relationships
├── Domain-area relationships ← ONLY IN ServiceTransfer
└── Area-category relationships
6. Supporting Reference Data
└── Activity groups
7. Outcomes Framework - Templates
├── Predefined outcomes
├── Consent types
└── Predefined outcome activities
Operation Sequence - ServiceTransferWithoutDomainRelationships
Same as ServiceTransfer except skips step 5 entirely (both relationship operations):
5. Outcomes Framework - Relationships
├── Domain-area relationships ← SKIPPED
└── Area-category relationships ← SKIPPED
Result: 16 operations instead of 18.
Dependency Chain
PRIMHD Teams (standalone)
↓
Contract Grouping → Grouping with parent references
↓
Contract Types → Funding Contracts → Contract Services
↓
Service Eligibility Rules (composite key: name + service)
↓
Service Types/Sites (supporting tables)
↓
Outcome Domains
↓
Domain Indicators (reference domains)
↓
Outcome Areas
↓
Outcome Categories
↓
Domain-Area Relationships [OPTIONAL] (reference domains + areas)
↓
Area-Category Relationships [OPTIONAL] (reference areas + categories)
↓
Predefined Outcomes (reference domains, areas, categories, services)
↓
Predefined Activities (reference predefined outcomes, services)
↓
Activity Groups (standalone)
Consent Types (standalone)
Tables Affected
PRIMHD Teams
Table: mag_primhdteam
Purpose: PRIMHD reporting team configuration
Fields:
mag_primhdteamid- GUID (preserved)mag_primhdcode- PRIMHD team codemag_primhdteamname- Team name (primary identifier)mag_teamcode- Team code
Special Handling:
- GUID preserved for consistency
- Name-based uniqueness checking
Example teams:
- Mental Health Team (code: MH01)
- Youth Services Team (code: YS02)
- Family Support Team (code: FS03)
Contract Grouping
Table: mag_grouping
Purpose: Hierarchical organisation of funding contracts
Fields:
mag_name- Grouping name (primary identifier)mag_description- Grouping descriptionmag_abbreviation- Grouping abbreviationmag_parentgrouping- Parent grouping reference
Two-Pass Processing:
First Pass - Create groupings:
Contract grouping ...
Processing: Health Services
+
Processing: Mental Health Services
+
Processing: Youth Mental Health
+
done
Second Pass - Link parent references:
Updating grouping parent references ...
Grouping: Mental Health Services
Parent: Health Services
Retrieved parent grouping from target: Health Services ([guid])
U
Grouping: Youth Mental Health
Parent: Mental Health Services
Retrieved parent grouping from target: Mental Health Services ([guid])
U
done
Why two passes:
- All groupings must exist before setting parent references
- Parent references resolved by name in target environment
- Supports multi-level hierarchies
Example hierarchy:
Health Services
├── Mental Health Services
│ ├── Youth Mental Health
│ └── Adult Mental Health
└── Physical Health Services
Funding Contract Types
Table: mag_contracttype
Purpose: Contract type definitions
Fields:
mag_name- Contract type name (primary identifier)mag_description- Descriptionmag_contracttypecode- Type code
Special Handling:
addToExistingData = true(allows adding to populated environments)- Name-based uniqueness
Example types:
- Service Delivery Contract
- Support Services Contract
- Assessment Contract
Funding Contracts
Table: mag_fundingcontract
Purpose: Funding contract records with dates and financial configuration
Scalar Fields:
mag_name- Contract name (primary identifier)mag_contractnumber- Contract numbermag_startdate,mag_expirydate- Contract periodmag_noticerequired- Notice period requiredmag_totalfunding- Total funding amountmag_usevoucherfunding- Use voucher funding flagmag_fundingrunoutdate- Funding run-out datemag_description- Contract description
EntityReference Fields (Resolved by mag_name):
mag_contracttype- Contract typemag_grouping- Contract groupingmag_billinggroup- Billing groupmag_currency- Currencymag_analysis1,mag_analysis2,mag_analysis3- Custom analysis lookupsmag_billinganalysis- Billing analysis
Special Handling - Date Validation:
⚠️ Dates before January 1, 1850 are set to NULL
This prevents errors from invalid or placeholder dates:
DateTime lowerLimit = new DateTime(1850, 1, 1);
if (contract["mag_startdate"] != null && (DateTime)contract["mag_startdate"] < lowerLimit)
{
contract["mag_startdate"] = null;
}
Why this matters:
- Some data migrations use very early dates as placeholders
- Dataverse has minimum date restrictions
- NULL is better than invalid date
Example contract:
Name: "Community Mental Health Services 2024"
Contract Number: "CMH-2024-001"
Start Date: 2024-01-01
Expiry Date: 2024-12-31
Contract Type: Service Delivery Contract
Grouping: Mental Health Services
Total Funding: $500,000
Contract Services
Table: mag_contractservice
Purpose: Services delivered under funding contracts
Scalar Fields:
Service identification:
mag_name- Service name (primary identifier)mag_servicecode- Service codemag_shortname- Short namemag_description- Service description
Configuration:
mag_active- Active statusmag_startdate,mag_enddate- Service periodmag_canclose- Can close flagmag_showonplans- Show on plans flagmag_globalenrolment- Global enrollment flagmag_consentexpirydays- Consent expiry daysmag_allowpastdatededit- Allow past date editmag_defaultnotcaptured- Default not captured flag
Assessment configuration:
mag_autocreateinitialassessment- Auto-create initial assessmentmag_autogeneratereassessments- Auto-generate reassessmentsmag_allowmultipleprimaryassessments- Allow multiple primary assessmentsmag_daysforautogeneratedreassessment- Days for auto-generated reassessmentmag_autocreateinitialassessmentdays- Auto-create initial assessment daysmag_riskassessmentmessage- Risk assessment message
Exit configuration:
mag_exitreasonrequired- Exit reason requiredmag_exitlockreason- Exit lock reasonmag_allowexitreasonchange- Allow exit reason changemag_allownoexit- Allow no exit
Financial configuration:
mag_isvoucherservice- Is voucher servicemag_voucherexpiryperiod- Voucher expiry periodmag_vouchervalue- Voucher valuemag_vouchermessage- Voucher message
EntityReference Fields (All Resolved by mag_name):
mag_fundingcontract- Parent funding contractmag_assessmenttype- Default assessment typemag_riskassessmenttype- Risk assessment typemag_defaultconsenttype- Default consent typemag_contractservicetype- Contract service typemag_contractservicesite- Contract service sitemag_currency- Currencymag_voucher- Voucher configurationmag_servicetransfer- Service transfer configurationmag_referralservice- Referral service
Special Handling - Date Validation: Same as funding contracts - dates before January 1, 1850 set to NULL
Example service:
Name: "Youth Mental Health Support"
Service Code: "YMHS"
Funding Contract: "Community Mental Health Services 2024"
Service Type: Mental Health Service
Start Date: 2024-01-01
End Date: 2024-12-31
Active: Yes
Show on Plans: Yes
Auto-create Initial Assessment: Yes
Days for Auto-generated Reassessment: 90
Exit Reason Required: Yes
Service Eligibility Rules
Table: mag_eligibilityrule
Purpose: Define who can enroll in services based on criteria
Primary Key: Composite key of mag_eligibilityrulename + mag_contractserviceid
Scalar Fields:
mag_eligibilityrulename- Rule name (part of composite key)mag_eligibilityrule- Rule logicmag_eligibilityrulecode- Rule codemag_allowenrolment- Allow enrollment flagmag_allowclosingenrolment- Allow closing enrollment flagmag_allowreferral- Allow referral flagmag_gender- Gender restrictionmag_minage,mag_maxage- Age range restrictions
EntityReference Fields (Resolved by mag_name):
mag_contractserviceid- Parent contract service (part of composite key)mag_agegroup- Age group restrictionmag_ethnicity- Ethnicity restrictionmag_levelofeducation- Education level restriction
⚠️ COMPOSITE KEY: Multiple rules can have the same name if associated with different services.
Special Handling in EntityHelper.CreateIfNew:
// Query for existing rule by NAME + SERVICE
QueryExpression query = new QueryExpression("mag_eligibilityrule");
query.Criteria.AddCondition("mag_eligibilityrulename", ConditionOperator.Equal, entity["mag_eligibilityrulename"]);
query.Criteria.AddCondition("mag_contractserviceid", ConditionOperator.Equal, entity["mag_contractserviceid"]);
// Console output shows both identifying fields
Console.Write($"Checking eligibility rule with name: {entity["mag_eligibilityrulename"]} and service ID: {serviceId}");
Console Output:
Eligibility rules ...
Checking eligibility rule with name: Youth Age Restriction and service ID: [guid]
Retrieved mag_name: Youth Mental Health Support
Creating new eligibility rule
+
Checking eligibility rule with name: Adult Age Restriction and service ID: [guid]
Retrieved mag_name: Adult Mental Health Support
Creating new eligibility rule
+
done
Why composite key:
- Same eligibility rule logic can apply to multiple services
- Service-specific age restrictions (e.g., "Youth" means different ages for different services)
- Allows copying rule templates across services
Example rules:
Rule: "Youth Age Restriction"
Service: Youth Mental Health Support
Min Age: 12
Max Age: 25
Allow Enrollment: Yes
Rule: "Youth Age Restriction" ← SAME NAME, DIFFERENT SERVICE
Service: Youth Substance Abuse
Min Age: 10
Max Age: 18
Allow Enrollment: Yes
Contract Service Types
Table: mag_contractservicetype
Purpose: Categorise contract services
Fields:
mag_name- Service type name (primary identifier)
Example types:
- Mental Health Service
- Family Support Service
- Youth Service
- Assessment Service
Contract Service Sites
Table: mag_contractservicesite
Purpose: Physical locations where services are delivered
Fields:
mag_name- Site name (primary identifier)mag_sitecode- Site codemag_sitedescription- Site description
Example sites:
- Auckland Central Clinic (code: AKL-CENTRAL)
- Christchurch Community Hub (code: CHC-COMM)
- Wellington Youth Centre (code: WLG-YOUTH)
Outcome Domains
Table: mag_domain
Purpose: Top-level outcome categorisation
Fields:
mag_name- Domain name (primary identifier)mag_outcomemap- Outcome mapping optionstatecode,statuscode- State information
See organizationsetup-outcomes.md for complete details.
Domain Indicators
Table: mag_outcomedomainindicator
Purpose: Measurable indicators within outcome domains
Fields:
mag_name- Indicator namemag_indicatorcode- Indicator codemag_outcomedomain- Parent domain referencestatecode,statuscode- State information
See organizationsetup-outcomes.md for complete details.
Outcome Areas
Table: mag_outcomearea
Purpose: Specific outcome areas spanning multiple domains
Fields:
mag_name- Area name (primary identifier)statecode,statuscode- State information
See organizationsetup-outcomes.md for complete details.
Outcome Categories
Table: mag_outcomecategory
Purpose: Detailed categorization within outcome areas
Fields:
mag_name- Category name (primary identifier)statecode,statuscode- State information
See organizationsetup-outcomes.md for complete details.
Domain-Area Relationships
Table: mag_mag_outcomearea_mag_domain
Purpose: Many-to-many relationships between domains and areas
⚠️ ONLY CREATED BY ServiceTransfer - The ServiceTransferWithoutDomainRelationships variant skips this operation.
Fields:
mag_domainid- Domain EntityReferencemag_outcomeareaid- Outcome area EntityReference
See organizationsetup-outcomes.md for complete details.
When to skip:
- Domain-area relationships already correct in target
- Updating services without changing outcome structure
- Performance optimisation (relationship creation can be slow)
Area-Category Relationships
Table: mag_mag_outcomecategory_mag_outcomearea
Purpose: Many-to-many relationships between areas and categories
⚠️ ONLY CREATED BY ServiceTransfer - The ServiceTransferWithoutDomainRelationships variant skips this operation (along with domain-area relationships).
Fields:
mag_outcomeareaid- Outcome area EntityReferencemag_outcomecategoryid- Outcome category EntityReference
See organizationsetup-outcomes.md for complete details.
Predefined Outcomes
Table: mag_predefinedoutcome
Purpose: Template outcomes linked to services
Key Fields:
mag_predefinedoutcomeid- GUID (preserved)mag_name- Outcome name (primary identifier)mag_service- Associated contract service (EntityReference)
Multiple EntityReferences:
- Service reference:
mag_service,mag_activitydefaultservice - Outcome framework references:
mag_domain1-3,mag_outcomearea1-3,mag_outcomecategory1-3 - Analysis references:
mag_analysis1-3
See organizationsetup-outcomes.md for complete details.
ServiceTransfer importance:
- Predefined outcomes often reference contract services
- Service references must resolve correctly
- Contract services created earlier in operation sequence ensure references work
Predefined Outcome Activities
Table: mag_predefinedactivity
Purpose: Template activities for predefined outcomes
Composite Key: mag_name + mag_service
Key Fields:
mag_name- Activity name (part of composite key)mag_service- Associated contract service (part of composite key)mag_predefinedoutcome- Parent predefined outcome
See organizationsetup-outcomes.md for complete details.
ServiceTransfer importance:
- Activities frequently reference contract services
- Service association enables service-specific activity templates
- Contract services must exist before activities can be created
Activity Groups
Table: mag_activitygroup
Purpose: Group activities for reporting and organisation
Fields:
mag_name- Activity group name (primary identifier)mag_activitygroupcode- Activity group codemag_description- Group descriptionmag_sortorder- Display sort ordermag_activitytype- Activity type optionmag_contactfacing- Contact facing flag
Example groups:
- Assessments (code: ASSESS, sort: 1, type: Assessment)
- Case Management (code: CASEMGMT, sort: 2, type: Case Work)
- Therapeutic Interventions (code: THERAPY, sort: 3, type: Clinical)
- Family Support (code: FAMILY, sort: 4, type: Support)
Why included in ServiceTransfer:
- Activity groups often align with service types
- Services typically use consistent activity categorisation
- Ensures activity tracking consistency across environments
Consent Types
Table: mag_consenttype
Purpose: Define consent types for services and activities
Fields:
mag_name- Consent type name (primary identifier)mag_consenttypecode- Consent type codestatecode,statuscode- State information
Special Handling:
- Verbose logging enabled (logs each field being copied)
- Useful for debugging consent type issues
Example consent types:
- Service Enrollment Consent (code: ENROL)
- Information Sharing Consent (code: INFOSHARE)
- Assessment Consent (code: ASSESS)
- Photography Consent (code: PHOTO)
Why included in ServiceTransfer:
- Services often have default consent types
- Contract services reference consent types
- Consent requirements vary by service type
Real-World Scenarios
Scenario 1: New Service Environment Setup
Context: Setting up new UAT environment with complete service infrastructure.
.\WhanauTahi.Xpm.Tooling.exe organizationsetup `
--MasterDataUrl "https://masterdata.crm6.dynamics.com" `
--EnvironmentUrl "https://uat.crm6.dynamics.com" `
--ClientId "12345678-1234-1234-1234-123456789abc" `
--DataSet "ServiceTransfer"
Expected Console Output:
Navigator environment prepration tool
Master Data: Whānau Tahi Master Data
Target System: UAT Environment
PRIMHD teams ...+++... done
Contract grouping ...+++... done
Updating grouping parent references ...UU... done
Funding contract types ...++... done
Funding Contracts ...++++... done
Contract Services ...+++++++... done
Eligibility rules ...
Checking eligibility rule with name: Youth Age Restriction and service ID: [guid]
Retrieved mag_name: Youth Mental Health Support
Creating new eligibility rule
+++++++... done
Contract service types ...+++... done
Contract service sites ...+++++... done
Outcome domains ...+++++... done
Domain indicators ...+++++++... done
Outcomne areas ...++++++++... done
Outcome categories ...+++++++++++... done
Domain-Area relationships ...++++... done
Area-Category relationships ...+++++... done
Predefined Outcome Activities ...++++++++++... done
Activity groups ...++++... done
Consent types ...+++... done
Environment preparation completed
Result: Complete service infrastructure ready for use in UAT.
Post-Deployment Validation:
- Review PRIMHD teams created
- Verify contract hierarchy (grouping → contracts → services)
- Check service eligibility rules
- Test creating enrollment with predefined outcome
- Confirm predefined activities auto-create
Scenario 2: Service Configuration Update with Existing Outcomes
Context: Production environment already has outcomes framework. Need to update service configuration only.
Strategy: Use ServiceTransferWithoutDomainRelationships to skip domain-area relationships (already correct).
.\WhanauTahi.Xpm.Tooling.exe organizationsetup `
--MasterDataUrl "https://masterdata.crm6.dynamics.com" `
--EnvironmentUrl "https://production.crm6.dynamics.com" `
--ClientId "12345678-1234-1234-1234-123456789abc" `
--DataSet "ServiceTransferWithoutDomainRelationships" `
--AddToExistingData `
--UpdateExisting
Why this approach:
ServiceTransferWithoutDomainRelationships- Skip domain-area relationshipsAddToExistingData- Production has existing servicesUpdateExisting- Update existing contract services with new configuration
Expected Console Output:
PRIMHD teams ...---U++... done
Contract grouping ...-UU+... done
Funding Contracts ...--UU++... done
Contract Services ...---UUUUU++... done
Eligibility rules ...--UUU+++... done
Outcome domains ...--------... done
Domain indicators ...--------... done
Outcomne areas ...--------... done
Outcome categories ...-U-U----... done
Domain-Area relationships ... ← SKIPPED
Area-Category relationships ...-----... done
Predefined Outcome Activities ...UUUUUU+++... done
Activity groups ...----U++... done
Consent types ...-----... done
Environment preparation completed
Console legend:
-= Skipped (already exists, no update needed)U= Updated existing record+= Created new record
Performance gain:
- Skipped domain-area relationships operation
- Faster execution (10-15% time savings)
Result:
- New PRIMHD teams added
- Contract services updated with new configuration
- New eligibility rules created
- Predefined activities updated
- Domain-area relationships left unchanged
Scenario 3: Multi-Environment Service Sync
Context: Synchronised service configuration across dev, test, UAT, and production.
Step 1 - Update master data:
- Make service configuration changes in master data environment
- Test changes within master data
- Document changes made
Step 2 - Deploy to dev (full sync):
.\WhanauTahi.Xpm.Tooling.exe organizationsetup `
--MasterDataUrl "https://masterdata.crm6.dynamics.com" `
--EnvironmentUrl "https://dev.crm6.dynamics.com" `
--ClientId "12345678-1234-1234-1234-123456789abc" `
--DataSet "ServiceTransfer" `
--UpdateExisting
Step 3 - Deploy to test (full sync):
.\WhanauTahi.Xpm.Tooling.exe organizationsetup `
--MasterDataUrl "https://masterdata.crm6.dynamics.com" `
--EnvironmentUrl "https://test.crm6.dynamics.com" `
--ClientId "12345678-1234-1234-1234-123456789abc" `
--DataSet "ServiceTransfer" `
--UpdateExisting
Step 4 - UAT testing:
.\WhanauTahi.Xpm.Tooling.exe organizationsetup `
--MasterDataUrl "https://masterdata.crm6.dynamics.com" `
--EnvironmentUrl "https://uat.crm6.dynamics.com" `
--ClientId "12345678-1234-1234-1234-123456789abc" `
--DataSet "ServiceTransfer" `
--UpdateExisting
Step 5 - Production deployment (optimised):
.\WhanauTahi.Xpm.Tooling.exe organizationsetup `
--MasterDataUrl "https://masterdata.crm6.dynamics.com" `
--EnvironmentUrl "https://production.crm6.dynamics.com" `
--ClientId "12345678-1234-1234-1234-123456789abc" `
--DataSet "ServiceTransferWithoutDomainRelationships" `
--AddToExistingData `
--UpdateExisting
Production deployment rationale:
- Use
ServiceTransferWithoutDomainRelationshipsfor faster execution - Domain-area relationships already correct (synced in previous deployment)
AddToExistingDataandUpdateExistingfor production safety
Result: All environments have identical service configuration.
Scenario 4: New Service Addition
Context: Adding new service to existing environment with minimal changes.
Changes in master data:
- Created new funding contract "Early Intervention 2024"
- Created new contract service "Youth Early Intervention"
- Added eligibility rules for new service
- Created predefined outcomes for new service
- Created predefined activities for new service
Deployment:
.\WhanauTahi.Xpm.Tooling.exe organizationsetup `
--MasterDataUrl "https://masterdata.crm6.dynamics.com" `
--EnvironmentUrl "https://production.crm6.dynamics.com" `
--ClientId "12345678-1234-1234-1234-123456789abc" `
--DataSet "ServiceTransferWithoutDomainRelationships" `
--AddToExistingData
Why these flags:
ServiceTransferWithoutDomainRelationships- Outcomes framework unchangedAddToExistingData- Production has existing services- NO
UpdateExisting- Only add new service, don't modify existing
Expected Console Output:
PRIMHD teams ...--------... done
Contract grouping ...--------... done
Funding contract types ...--------... done
Funding Contracts ...------+... done (1 new)
Contract Services ...----------+... done (1 new)
Eligibility rules ...--------+++... done (3 new)
Outcome domains ...--------... done
Predefined Outcome Activities ...---------+++... done (3 new for new service)
Activity groups ...--------... done
Consent types ...--------... done
Environment preparation completed
Result: New service added without affecting existing services.
Scenario 5: Post-Refresh Service Restoration
Context: Refreshed test environment from production backup. Need to restore test-specific service configuration.
Challenge: Test environment now has production service configuration. Want test-specific services restored.
Solution:
.\WhanauTahi.Xpm.Tooling.exe organizationsetup `
--MasterDataUrl "https://testmasterdata.crm6.dynamics.com" `
--EnvironmentUrl "https://refreshedtest.crm6.dynamics.com" `
--ClientId "12345678-1234-1234-1234-123456789abc" `
--DataSet "ServiceTransfer" `
--AddToExistingData `
--UpdateExisting
Why this works:
testmasterdataenvironment contains test-specific service configurationAddToExistingDataallows adding to environment that has production servicesUpdateExistingoverwrites production services with test-specific versions- Test-specific predefined outcomes and activities restored
Result: Test environment has test-specific services while preserving production-like data.
Best practice:
- Maintain separate master data for test-specific configuration
- Document which services are test-only vs production
- Consider using service naming conventions (e.g., "TEST-" prefix)
Performance Considerations
Typical Execution Time
ServiceTransfer: 3-7 minutes ServiceTransferWithoutDomainRelationships: 2.5-6 minutes
Breakdown (ServiceTransfer):
- PRIMHD teams: 5-10 seconds
- Contract grouping (2 passes): 20-40 seconds
- Funding contract types: 5-10 seconds
- Funding contracts: 15-30 seconds
- Contract services: 30-90 seconds
- Eligibility rules: 20-60 seconds
- Contract service types/sites: 10-20 seconds
- Outcome domains/indicators: 15-30 seconds
- Outcome areas/categories: 15-30 seconds
- Domain-area relationships: 15-45 seconds ← SKIPPED IN VARIANT
- Area-category relationships: 15-45 seconds
- Predefined outcomes: 20-40 seconds
- Predefined activities: 30-90 seconds
- Activity groups: 10-20 seconds
- Consent types: 5-15 seconds
Performance gain with ServiceTransferWithoutDomainRelationships:
- Saves 15-45 seconds (domain-area relationships)
- Approximately 10-15% faster
- Most beneficial when domain-area relationships are numerous
Factors affecting duration:
- Number of contract services (can be dozens)
- Number of eligibility rules (multiple per service)
- Number of predefined outcomes and activities (can be hundreds)
- Complexity of contract grouping hierarchy
- Network latency between environments
- Use of
UpdateExistingflag (slower than create-only)
Optimisation Tips
For faster execution:
- Use
ServiceTransferWithoutDomainRelationshipsif domain-area relationships unchanged - Run during off-peak hours
- Use default flags when possible (no AddToExistingData or UpdateExisting)
- Minimise test/template data in master data environment
For large service catalogs:
- Monitor console output for stalled operations
- Check for eligibility rule resolution failures
- Consider splitting into smaller deployments if needed
- Review contract service count (dozens of services can slow execution)
For repeated deployments:
- Use
ServiceTransferWithoutDomainRelationshipsfor service-only updates - Skip unnecessary operations by choosing appropriate DataSet
- Consider datamanipulation tool for single-table updates
Troubleshooting
Grouping Parent References Not Set
Problem: Contract grouping created but mag_parentgrouping is NULL
Cause: Second pass (parent reference update) failed
Solution:
- Check console output for "Updating grouping parent references" section
- Verify parent grouping exists in target environment
- Check for name mismatch between source and target
- Ensure all groupings created before second pass begins
Contract Service Creation Fails
Problem: "Could not resolve [reference] for contract service"
Cause: Referenced entity doesn't exist in target
Solution:
- Check operation order - contract types must exist before contracts
- Verify funding contract exists before creating contract services
- Check service type and service site exist in target
- Review assessment type references
- Ensure consent types created
Eligibility Rule Duplicates
Problem: Multiple eligibility rules with same name but different services
Cause: This is normal - composite key allows same name for different services
Solution:
- Review
mag_contractserviceidfield on rules - Verify each rule is associated with correct service
- This is expected behavior if services require same eligibility logic
Predefined Activity Missing Service Reference
Problem: Predefined activity created but mag_service is NULL
Cause: Service reference couldn't be resolved
Solution:
- Verify contract services operation completed successfully
- Check service name in template matches target
- Review console output for EntityReference resolution errors
- Ensure service exists before creating predefined activities
Date Fields Set to Null
Problem: Contract or service date fields are NULL despite having dates in template
Cause: Source dates before January 1, 1850 (invalid dates)
Solution:
- Review source data for placeholder dates
- Update template data with valid dates (>= 1850-01-01)
- Re-run organizationsetup
- NULL is expected if source has invalid dates
PRIMHD Team Not Created
Problem: PRIMHD team from template not appearing in target
Cause: Duplicate name or GUID conflict
Solution:
- Check console output for team creation errors
- Verify team doesn't already exist with different GUID
- Review idempotent behavior (skips if exists)
- Use
UpdateExistingif need to update existing team
Domain-Area Relationships Missing (ServiceTransfer)
Problem: Used ServiceTransfer but domain-area relationships not created
Cause: Relationship creation failed or was skipped
Solution:
- Check console output for "Domain-Area relationships" section
- Verify outcome domains and areas exist in target
- Check for name resolution errors
- Ensure domains and areas created before relationships
- Review console for "Couldn't find matching domain or area in target"
Performance Degradation
Problem: ServiceTransfer taking much longer than expected (>10 minutes)
Cause: Large number of services, outcomes, or complex relationships
Solution:
- Use
ServiceTransferWithoutDomainRelationshipsif appropriate - Check for network latency issues
- Review master data for excessive test/template data
- Consider cleaning up unused predefined outcomes/activities
- Monitor console to identify slow operation
Best Practices
Master Data Management
Service template environment:
Maintain production-like services:
- Keep master data aligned with production services
- Document service configuration standards
- Use consistent naming conventions
Contract hierarchy:
- Design logical grouping structure (2-3 levels max)
- Use meaningful grouping names
- Avoid circular parent references
Service configuration:
- Set realistic dates (after 1850-01-01)
- Configure assessment auto-creation appropriately
- Define exit reason requirements
- Set consent expiry days
Eligibility rules:
- Use clear, descriptive rule names
- Document eligibility logic
- Test eligibility rules before deployment
- Consider service-specific vs shared rules
Predefined outcomes:
- Link outcomes to appropriate services
- Set realistic durations
- Configure domain/area/category associations
- Test outcome creation flow
Predefined activities:
- Configure timing appropriately (start after, due after)
- Link to correct assessment tools
- Set consent type requirements
- Test activity auto-creation
Change Management
Before making service changes:
✅ Document current service configuration
✅ Identify impact of proposed changes
✅ Plan rollback strategy
✅ Test changes in development environment
✅ Get stakeholder approval
✅ Schedule deployment window
✅ Communicate to users
Service configuration versioning:
- Maintain documentation of service catalog versions
- Tag master data environment with version/date
- Keep change log of service modifications
- Document reasons for configuration changes
Testing workflow:
- Make changes in master data environment
- Deploy to development using ServiceTransfer
- Test enrollment flow with new services
- Verify eligibility rules work correctly
- Test predefined outcome/activity auto-creation
- UAT with end users
- Deploy to production during scheduled maintenance
DataSet Selection Strategy
Use ServiceTransfer when:
- Setting up new environment
- Complete service infrastructure sync needed
- Outcomes framework changed alongside services
- First deployment to environment
Use ServiceTransferWithoutDomainRelationships when:
- Updating existing environment
- Outcome domain structure unchanged
- Only service configuration changed
- Performance optimisation needed
- Domain-area relationships already correct
Decision tree:
Need to deploy service configuration?
├─ Yes → New environment?
│ ├─ Yes → ServiceTransfer (full setup)
│ └─ No → Outcomes changed?
│ ├─ Yes → ServiceTransfer (include relationships)
│ └─ No → ServiceTransferWithoutDomainRelationships (faster)
└─ No → Consider OutcomesFramework or datamanipulation
Validation Checklist
After ServiceTransfer deployment:
PRIMHD Configuration:
✅ PRIMHD teams created
✅ Team codes match template
Contract Infrastructure:
✅ Contract groupings created
✅ Parent grouping references set correctly
✅ Funding contract types present
✅ Funding contracts created with correct dates
✅ Contract services present and active
Eligibility:
✅ Eligibility rules created
✅ Age restrictions configured correctly
✅ Service associations correct
Supporting Tables:
✅ Contract service types present
✅ Contract service sites present
✅ Activity groups created
✅ Consent types present
Outcomes Framework:
✅ Outcome domains, areas, categories present
✅ Domain-area relationships created (if using ServiceTransfer)
✅ Area-category relationships created
✅ Predefined outcomes linked to services
✅ Predefined activities linked to outcomes and services
Integration Testing:
✅ Create test enrollment in contract service
✅ Verify eligibility rules enforced
✅ Add predefined outcome to plan
✅ Confirm predefined activities auto-create
✅ Test assessment tool linkage
✅ Verify consent type functionality
Incremental Updates
For ongoing service maintenance:
Update master data:
- Make service configuration changes
- Update eligibility rules as needed
- Modify predefined outcomes/activities
- Test changes
Deploy to dev:
--DataSet "ServiceTransferWithoutDomainRelationships" --UpdateExisting- Test deployment
- Verify updates applied
Deploy to test/UAT:
- Same command to test/UAT
- Conduct user testing
- Validate service changes
Production deployment:
- Schedule deployment window
- Communicate to users
- Deploy with appropriate flags
- Monitor for issues
- Verify critical services still working
Rollback plan:
- Keep backup of service configuration before changes
- Document all modifications made
- Test rollback in dev environment first
- Be prepared to restore from backup if needed
Environment-Specific Considerations
Development:
- Use
ServiceTransferfor complete rebuilds - Test new service configurations
- Experiment with eligibility rules
- Validate predefined outcome flows
Test/UAT:
- Use
ServiceTransferor optimised variant - Mirror production service catalog
- Add test-specific services if needed
- Validate changes before production
Production:
- Use
ServiceTransferWithoutDomainRelationshipswhen appropriate - Always use
AddToExistingDataandUpdateExistingflags - Schedule during maintenance windows
- Monitor console output carefully
- Validate critical services immediately after deployment
Disaster Recovery
Include service configuration in DR plan:
Backup master data:
- Regular automated backups
- Export service configuration before major changes
- Store exports securely
- Document master data environment details
Document deployment commands:
- Save complete organizationsetup commands
- Note DataSet options used
- Document any special flags
- Keep version history
Test recovery process:
- Periodically restore to test environment
- Verify service configuration restores correctly
- Validate contract hierarchies
- Test enrollment flows
Recovery sequence:
- Restore Dataverse environment
- Run organizationsetup with ServiceTransfer DataSet
- Verify contract grouping hierarchy
- Validate eligibility rules
- Test predefined outcome functionality
- Confirm PRIMHD teams present
Tables Summary
The ServiceTransfer DataSet affects 18 tables:
PRIMHD:
mag_primhdteam- PRIMHD teams
Contracts:
2. mag_grouping - Contract grouping
3. mag_contracttype - Funding contract types
4. mag_fundingcontract - Funding contracts
5. mag_contractservice - Contract services
6. mag_eligibilityrule - Service eligibility rules
7. mag_contractservicetype - Contract service types
8. mag_contractservicesite - Contract service sites
Outcomes Foundation:
9. mag_domain - Outcome domains
10. mag_outcomedomainindicator - Domain indicators
11. mag_outcomearea - Outcome areas
12. mag_outcomecategory - Outcome categories
Outcomes Relationships:
13. mag_mag_outcomearea_mag_domain - Domain-area relationships
14. mag_mag_outcomecategory_mag_outcomearea - Area-category relationships
Outcomes Templates:
15. mag_predefinedoutcome - Predefined outcomes
16. mag_predefinedactivity - Predefined outcome activities
Supporting:
17. mag_activitygroup - Activity groups
18. mag_consenttype - Consent types
The ServiceTransferWithoutDomainRelationships DataSet affects 17 tables (excludes #13: Domain-area relationships).