✅ Step-by-Step Code Upgrade
Procedure (AX 2012 → D365FO using LCS)
PHASE 1 – Pre-upgrade Preparation (AX 2012)
1️ Validate AX 2012 Version
- You
must be on AX 2012 R2 CU7+ or AX 2012 R3 CU8+.
- Apply
latest kernel + application hotfixes.
- Run Code
upgrade checklist in AX.
2️ Clean up AX 2012 AOT
Before exporting the code model store:
- Delete
unused models
- Delete
obsolete/custom objects not needed in D365
- Fix
compile errors
- Run
full CIL generation
- Run
consistency check
- Remove
suspended/old workflows
- Remove
references to deprecated features
3️ Export AX 2012 Model Store
Use PowerShell:
Export-AXModelStore -File
"C:\ModelStore.axmodelstore"
This exported file will be uploaded to LCS in the next
steps.
PHASE 2 – LCS Project Setup & Code Upgrade
4️ Create an LCS Project
- Go to
https://lcs.dynamics.com
- Create
a new project
- Select
Upgrade methodology
- Fill
project details → Industry, Region, Version
5️ Run the LCS Upgrade Analysis
Steps:
- Open Upgrade
Project in LCS
- Go to
Upgrade → Code Upgrade
- Upload
your AX 2012 model store file
- Choose
Target version (D365FO PU version)
- Submit
for analysis
6️ LCS Generates a Code Upgrade Report
After processing, LCS provides output:
✔ Code Analysis Report
- List
of conflicts
- Deprecated
frameworks
- Required
refactoring
- SSRS
report replacements
✔ Data Upgrade Report
- AOT
table changes
- Deprecated
fields
- Mapping
issues
✔ Customization Impact Report
- Which
customizations can be merged
- Which
must be redesigned (because of extensions)
You can download the generated .zip containing:
- Visual
Studio projects
- Conflict
lists
- HTML
analysis reports
PHASE 3 – Developer VM Setup (D365FO Dev Box)
7️ Deploy a Dev Box via LCS
Steps:
- Go to
your LCS project
- Environment
→ “+ Add”
- Choose
Development/Test
- Deploy
using your Azure subscription
- Once
deployed, connect using RDP
8️ Import the Upgraded Code into Dev Box
- Open
Visual Studio (Admin mode) in the VM
- Create
a new Model for your upgraded code
- Import
the code upgrade output from LCS
- Resolve
references
PHASE 4 – Conflict Resolution & Code Refactoring
9️ Fix conflicts & deprecated features
You must manually adjust:
- Overlayering
→ Convert to Extension
- Deprecated
methods → Replace with new APIs
- Forms
→ Rebuild or extend using Form Extensions
- Reports
→ Convert RDP reports to DP → Contract → Controller
- Customizations
→ Move to new extension model
1️0 Recompile the Entire Solution
In Visual Studio:
- Build
Model
- Build
Solution
- Synchronize
database
- Fix
compilation errors
- Rebuild
until no errors/warnings remain
1️1️ Resolve Data Upgrade Scripts
- Check
tables that need mapping
- Use Data
Entity framework
- Create
mappings for custom fields
- Adjust
surrogate keys, replaced indexes
PHASE 5 – Testing & Validation
1️2️ Execute Unit Tests
Test:
- Custom
classes
- Extended
methods
- Batch
jobs
- Custom
workflows
- Security
roles
1️3️ Functional Testing
- Perform
scenario testing
- Validate
customizations
- Validate
integrations
- Validate
reports (SSRS)
- Validate
workflows
1️4️ Perform Data Upgrade Testing
Using:
- Data
Upgrade tool
- Data
task automation (DTA)
- Export/Import
via Data Entities
PHASE 6 – Prepare for Go-Live
1️5️ Deploy to Test/UAT Environment
Using LCS:
- Create
a Deployable Package (DP)
- Upload
the package to LCS Asset Library
- Apply
to UAT environment
1️6️ Conduct UAT with Business Users
- Master
data validation
- Transaction
data validation
- Security
+ role testing
1️7️ Final Cutover Plan
Prepare:
- Backup
AX 2012
- Freeze
code
- Freeze
transactions
- Final
data export
- Execute
final data upgrade scripts
1️8️ Go-Live
- Deploy
final build to Production
- Run
data upgrade
- Validate
business processes
✅ PHASE 1 — Pre-Upgrade
Preparation in AX 2012 (Step-by-Step)
This phase ensures your AX 2012 environment is stable,
clean, and ready for the upgrade analysis.
Step 1: Identify AX Version and CU Level
✔ Actions
- Login
to AX 2012 client
- Go
to: Help → About Microsoft Dynamics AX
- Verify:
- Version
(R2 / R3)
- Cumulative
Update (CU)
✔ Requirements
- Minimum
recommended versions:
- AX
2012 R2 → CU7 or above
- AX
2012 R3 → CU8 or above
✔ If not updated
- Download
kernel + application hotfixes from LCS
- Apply
via AXUpdateInstaller
Step 2: Check Environment Health (AOS, DB, Services)
✔ Actions
- Restart
AOS services
- Validate
AOS event logs
- Validate
SQL Server services
- Test
database consistency:
- Index
fragmentation
- Large
log file size
- Orphan
sessions
This ensures smooth export later.
Step 3: Clean Up AOT (Models, Layers, Unused Objects)
✔ Actions
- Remove
unused models in AOT
- Delete
obsolete custom objects
- Remove
demo code or test projects
- Fix
naming conventions if possible
- Validate
security roles cleanup
✔ Tools
- axutil
list (PowerShell) to list models
- axutil
delete to remove unwanted models
Step 4: Fix Compilation Errors
✔ Actions
- Open
AX Development Workspace
- Compile
the entire AOT (F7)
- Fix
all compilation errors
- Fix
best practice (BP) errors where required
✔ Common issues
- Missing
references
- Obsolete
.NET assemblies
- Inconsistent
table/field IDs
Step 5: Run Full CIL Generation
✔ Actions
- Go
to System Administration → Periodic → Compile
- Select
Generate Full CIL
- Let
it complete successfully.
✔ If it fails
- Review
CIL logs
- Fix
X++ compile errors
- Retry
generation
Step 6: Check DB Consistency (Consistency Check)
✔ Actions
- Go
to:
- System
Administration → Periodic → Database → Consistency Check
- Select
tables:
- Invent
- Ledger
- Sales
- Purch
- HRM
- Projects
- Run
checks
✔ Resolve:
- Mismatched
relations
- Missing
records
- Invalid
dimension combinations
Step 7: Validate Workflows (Clean up suspended ones)
✔ Actions
- Go
to System Administration → Workflow → Work Item History
- Delete:
- Suspended
workflows
- Failed
workflows
- Long-pending
workflows
- Clean
up workflow batch jobs
✔ Why needed
- Workflows
cannot be upgraded to D365 as-is
- Reduces
errors during model store export
Step 8: Cleanup Enterprise Portal (EP) Components
(EP is deprecated in D365)
✔ Actions
- Identify
EP forms/pages
- Document
those that need replacement
- Remove
unused EP customizations
- Disable
EP batch jobs
Step 9: Clean Up AIF & Legacy Integrations
✔ Actions
- Identify
AIF inbound/outbound ports
- Export
the AIF configuration
- Disable
unused ports
- Remove
obsolete AIF classes if possible
- Document
integrations for redesign in D365
Step 10: Validate Security Model
✔ Actions
- Review
custom security roles in AOT
- Validate:
- Duties
- Privileges
- Permissions
- Remove
old roles not required
- Document
custom security for recreation in D365
Step 11: Documentation of Customizations
✔ Actions
Create a detailed list of:
- Custom
tables
- Custom
classes
- Custom
forms
- Modified
standard objects
- Reports
(SSRS/AX queries)
- Integrations
- Batch
jobs
✔ Tip
Use:
- Model
store comparison tools
- XPO
export lists
Step 12: Clean Up Application Data
✔ Actions
- Delete
test transactions
- Remove
old data from:
- SysException
- Event
inbox
- Batch
history
- Workflow
history
- Reduce
DB size
✔ Why needed
Smaller DB → faster export → better LCS performance
Step 13: Validate Label Files
✔ Actions
- Export
custom label files
- Document
label IDs
- Remove
unused label files
- Merge
duplicate labels
Step 14: Backup AX 2012 Environment
✔ Backup Required
- SQL
DB backup (.bak)
- AOS
registry settings
- Model
store backup
- Custom
code (XPO export if needed)
- SSRS
configuration
✔ Validation
- Ensure
backup is restorable in test environment
Step 15: Export Model Store for LCS
✔ Actions (PowerShell):
Export-AXModelStore -File
"C:\ModelStore.axmodelstore"
✔ Pre-checks
- No
suspended sessions
- No
compilation errors
- CIL
is clean
Step 16: Prepare the Model Store for Upload
✔ Actions
- Zip
the file
- Ensure
size is acceptable
- Confirm
model store matches desired CU level
📌 Summary Table —
Timeline for Each Step
Step
|
Task
|
Avg Time
|
1
|
Identify version/CU
|
1 day
|
2
|
Environment validation
|
1–2 days
|
3
|
AOT cleanup
|
2–7 days
|
4
|
Fix compilation issues
|
3–10 days
|
5
|
CIL generation
|
1 day
|
6
|
Consistency check
|
2–3 days
|
7
|
Workflow cleanup
|
1–2 days
|
8
|
EP clean up
|
2–3 days
|
9
|
AIF clean up
|
2–4 days
|
10
|
Security model validation
|
2–3 days
|
11
|
Customization documentation
|
3–10 days
|
12
|
Data cleanup
|
2–5 days
|
13
|
Label cleanup
|
2–3 days
|
14
|
Take backups
|
1 day
|
15
|
Export model store
|
Half day
|
16
|
Prepare for upload
|
1 day
|
🔥 Common Challenges in
Phase 1
1️⃣ Compilation errors in AOT
Large legacy codebases often have:
- Customizations
in SYS layer
- Overlayered
standard forms
- Incorrect
table relations
2️⃣ CIL Generation failures
Caused by:
- Bad
X++ code
- Missing
.NET assemblies
- Uncompiled
reports
3️⃣ Database corruption or
inconsistencies
Especially in:
- InventDim
- LedgerJournalTrans
- Workflow
tables
4️⃣ Large workflow backlogs
Blocking CIL and export processes.
5️⃣ AIF jobs stuck or corrupted
Old AIF pipelines break export tools.
6️⃣ EP components outdated
Enterprise Portal is deprecated → cleanup required.
7️⃣ Missing documentation for
custom objects
Makes code upgrade much harder later.
✅ PHASE 2 — LCS Code Upgrade
(Step-by-Step Procedure)
This phase begins after you have exported your AX 2012 model
store and ends when you get the code upgrade report.
Step 1: Log in to LCS and Create (or Open) Upgrade
Project
✔ Actions
- Go
to https://lcs.dynamics.com
- Sign
in using your org account.
- Create
a new project
- Select
Upgrade methodology
✔ Outputs
- LCS
project created with upgrade tasks enabled
✔ Time Required
Step 2: Open “Upgrade” Menu and Select “Code Upgrade”
✔ Actions
- In
LCS project → go to Upgrade tab
- Click
Code Upgrade
- A
new upgrade request page opens
✔ What you see:
- Option
to upload AX 2012 model store
✔ Time Required
Step 3: Upload AX 2012 Model Store to LCS
✔ Actions
- Click
Upload model store
- Choose
your ModelStore.axmodelstore file
- Provide
environment details:
- AX
version (R2/R3)
- CU
level
- Click
Submit
✔ Prerequisites
Ensure:
- Model
store is from cleaned AX environment
- File
is zipped if large
- Size
below LCS limit (~5–7 GB)
✔ Time Required
- Upload
time: 1–4 hours (depends on file size + network speed)
Step 4: LCS Performs Code Upgrade Analysis
✔ What LCS Does Automatically
- Decompiles
AX 2012 metadata
- Converts
X++ code to D365 standard format
- Detects
conflicts between:
- Microsoft
base code vs Customizations
- Identifies:
- Deprecated
APIs
- Overlayered
customizations
- AIF/EP
components
- Reports
that must be refactored
- Auto-generates
patch models
✔ Time Required
- LCS
processing: 2–4 days
- Large
environments: 5–7 days
✔ You Receive:
- Email
notification when analysis completes
✔ Common Problems
- Model
store inconsistent
- Missing
metadata
- Wrong
AX version selected
- Upload
corrupted
Step 5: Download Upgrade Analysis Results from LCS
✔ Actions
- Go
to LCS → Code Upgrade
- Click
Download Results
- Extract
the ZIP file
✔ Content Inside ZIP:
- Conflict
Report (HTML)
- Code
Merge Result (Visual Studio projects)
- Deprecated
features file
- Customizations
list
- Upgraded
VS solution
- Extension
recommendations
✔ Time Required
- 30
minutes to download and extract
Step 6: Review and Categorize LCS Output
✔ Actions
Analyze the following:
1️⃣ Conflict Summary Report
It shows:
- Modified
objects
- Overlayered
methods
- Conflicts
that require manual merge
2️⃣ Deprecated Feature Report
Includes:
- AIF
- EP
- MorphX
reports
- VE/SDS
- Legacy
BI cubes
3️⃣ Extension Recommendations
LCS identifies:
- Which
objects must be extended
- Which
can be auto-resolved
- Which
require redesign
4️⃣ Visual Studio Solution
Contains the upgraded code structure for D365, including:
- Project
files
- Model
definitions
- Temp
models
✔ Time Required
- Small
customization: 2–4 days
- Medium:
1–2 weeks
- Large:
3–4 weeks
Step 7: Prepare a Technical Impact Assessment Document
✔ Include:
- Summary
of conflicts
- Number
of objects needing manual merge
- Deprecated
components requiring redesign
- Effort
estimation
- Modules
impacted
- Priority
classification:
- High
(critical functionalities)
- Medium
(modify but not redesign)
- Low
(optional or phased out)
✔ Time Required
Step 8: Share Findings With Stakeholders
✔ Who should review:
- Technical
Lead
- Solution
Architect
- Functional
Leads
- Dev
Team
- Project
Manager
✔ Focus on:
- Impact
of overlayering
- Rework
required due to deprecated features
- Redesign
areas (workflows, EP, customization)
- Resource
planning for Phase 3
✔ Time Required
- 1–2
days for review workshops
📘 Summary – LCS Code
Upgrade Steps
|
Step
|
Description
|
Avg Time
|
1
|
Create LCS Upgrade Project
|
1 day
|
2
|
Start Code Upgrade process
|
15 mins
|
3
|
Upload model store
|
1–4 hrs
|
4
|
LCS processing
|
2–7 days
|
5
|
Download results
|
30 mins
|
6
|
Analyze upgrade output
|
2–4 weeks
|
7
|
Prepare impact document
|
3–5 days
|
8
|
Conduct review meetings
|
1–2 days
|
🔥 Common Challenges in
LCS Code Upgrade Phase
1️⃣ LCS upload failures
Reasons:
- Unzipped
files too large
- Model
store corrupt
- Wrong
version or CU
2️⃣ LCS processing delays
Because:
- Long
processing queues
- Huge
model store
- Complex
customizations
3️⃣ Massive number of conflicts
Caused by:
- Years
of overlayering
- Unsupported
patterns
- ISV
solutions not upgraded
4️⃣ AIF / EP Customizations
Since they are deprecated:
- Cannot
be automatically upgraded
- Must
be redesigned completely
5️⃣ Reports not migrating
RDP reports must be redesigned as:
- DP
class
- Contract
class
- Controller
class
6️⃣ Missing documentation for
customizations
Difficult to understand purpose of old modifications.
7️⃣ TFS/Git structure missing
Codebase not structured properly for D365 version control.
✅ PHASE 3 — D365FO Development
& Refactoring (Step-by-Step)
This is the longest and most complex phase of the AX
2012 → D365 upgrade.
Step 1: Provision a Cloud-Hosted Dev Box in LCS
✔ Actions
- In
LCS, go to Environment → Cloud-hosted environments
- Select
Add
- Choose:
- Tier
1 (Dev/Test)
- VM
with Visual Studio installed
- Provide
Azure subscription details
- Deploy
the environment
✔ Time
- Provisioning
time: 4–8 hours
✔ Challenges
- Slow
VM creation
- Azure
subscription permissions missing
- VM
size not sufficient for full compile
Step 2: Connect to the Dev VM
✔ Actions
- Click
Connect in LCS
- Download
RDP file
- Login
with credentials
- Open
Visual Studio as Administrator
✔ Validate:
- SQL
DB running
- AOS
service running
- Build
environment configured
Step 3: Import the LCS Upgrade Package into Visual Studio
✔ Actions
- Extract
the ZIP from LCS
- Copy
the upgraded models folder to:
- C:\AOSService\PackagesLocalDirectory
- Import
using VS:
- Dynamics
365 → Model Management → Import model
✔ Results
- Upgraded
code now appears in AOT under Private Models
✔ Challenges
- Missing
references
- Model
import failures
- Wrong
model mapping
Step 4: Resolve Broken References and Dependencies
✔ Actions
- Review
model references under:
- AOT
→ Models → <YourCustomModel>
- Add
required references:
- Application
suite
- Application
platform
- Data
types
- ISV
models
- Remove
invalid or deprecated references
✔ Typical Missing References:
- Ledger
- Workflow
- Dimension
framework
- Retail
Step 5: Resolve X++ Compilation Errors
✔ Actions
- Run full
build of your custom models only
- Fix
errors such as:
- Missing
methods
- Wrong
table fields
- Deprecated
APIs
- Incorrect
enum values
- Replace
deprecated methods with D365 equivalents
Common Deprecated APIs
AX 2012
|
D365 Replacement
|
strFmt
|
strFmt / global functions
|
infoLog.add
|
infolog.add
|
AIF APIs
|
Data entities
|
EP forms
|
Workspaces / Forms
|
Step 6: Convert Overlayered Code to Extensions
✔ Actions
For each overlayered object identified in LCS:
- Create
extension model
- Create
form extensions instead of modifying forms
- Create
class extensions (Chain of Command) instead of overriding methods
✔ Example CoC pattern:
[ExtensionOf(classStr(SalesFormLetter))]
final class SalesFormLetter_Extension
{
public void update()
{
next update();
// custom code
}
}
Step 4:
✔ Remember:
- Do
NOT modify SYS/SYP layers
- Must
use CoC for almost all overrides
Step 7: Rebuild Custom Tables and Data Structures
✔ Actions
- Convert
table customizations into table extensions
- Create
new fields using extensions
- Validate:
- Resolve
mismatched field IDs
✔ Challenges
- Shared
tables (InventDim, DirParty) changed structure
- Old
field IDs causing sync failures
Step 8: Rebuild and Redesign SSRS Reports
✔ Actions
- Convert
AX 2012 RDP-based reports to:
- Data
Provider Class (DP)
- Contract
Class
- Controller
Class
- Redesign
report layouts in Visual Studio
✔ Common Problems
- Query-based
reports failing due to metadata differences
- Custom
designs need to be recreated manually
Step 9: Rebuild Integrations Using Data Entities
✔ Actions
Replace legacy AIF or custom services with:
- OData
- Custom
data entities
- Batch
data API
✔ Tasks
- Create
new entity or extend standard entity
- Map
fields
- Handle
staging vs direct mode
Step 10: Configure Batch Jobs and Business Events
✔ Actions
- Identify
old batch classes
- Rewrite
in D365 if needed
- Use:
- SysOperation
framework
- Business
events
- Recurring
batch jobs
✔ Challenges
- Legacy
batch classes deprecated
- Missing
SysOperation patterns
Step 11: Recompile Entire Application
✔ Actions
- Run
Full Build for all models
- Fix
all remaining errors
- Run
full DB sync
- Validate
labels
✔ Time
- Compile
time: 3–6 hours
- Fixing
errors: days to weeks
Step 12: Unit Testing & Smoke Testing
✔ Actions
- Test
forms, classes, reports
- Validate:
- Posting
routines
- Business
logic
- Integrations
- Log
defects in DevOps
📌 Summary Table — Phase 3
Steps & Time
Step
|
Task
|
Time
|
1
|
Provision Dev VM
|
4–8 hrs
|
2
|
Connect to VM
|
30 mins
|
3
|
Import upgrade package
|
1–2 days
|
4
|
Resolve references
|
2–7 days
|
5
|
Fix compile errors
|
2–6 weeks
|
6
|
Convert to extensions
|
4–12 weeks
|
7
|
Fix tables/data model
|
1–3 weeks
|
8
|
Rebuild reports
|
2–6 weeks
|
9
|
Rebuild integrations
|
2–8 weeks
|
10
|
Configure batch jobs
|
1–2 weeks
|
11
|
Full compile + sync
|
1–2 days
|
12
|
Basic testing
|
1–3 weeks
|
🔥 Top Challenges in Phase
3
- Huge
volume of overlayered code
- Deprecated
features (AIF, EP, reports)
- Missing
or changed data structures
- Chain
of Command limitations
- Build
errors taking hours each cycle
- Metadata
inconsistencies
- Refactoring
custom reports
- Integrations
must be rebuilt
- Custom
workflows require redesign
- Performance
issues in dev VM
✅ PHASE 4 – Conflict Resolution
& Code Refactoring
This phase takes place after the code upgrade is imported
into D365FO and focuses on resolving conflicts, fixing compilation errors,
restructuring customizations to follow D365 extension patterns, and cleaning up
deprecated or incompatible code.
🔧 Step-by-Step Procedure
Step 1: Analyze Conflict Report from Code Upgrade Tool
Objective: Identify all upgrade conflicts generated
during code merge.
Tasks:
- Open
the upgrade report from LCS Code Upgrade tool.
- Categorize
conflicts into:
- Table
conflicts
- Class
conflicts
- Form
conflicts
- EDT/Enum
conflicts
- Deprecated
API conflicts
- Mark
items requiring extension vs rewrite vs removal.
Output: Categorized conflict list.
Step 2: Resolve Overlayering Conflicts
Objective: Convert AX 2012 overlayered customizations
into D365 extensions.
Tasks:
- Open
each conflict in Visual Studio.
- Replace
overlayered elements with:
- Extensions
- Event
handlers (pre/post)
- Chain-of-command
- Remove
direct code changes from SYS/SYP layers.
- Ensure
solution follows Microsoft’s extensibility guidelines.
Output: Clean extension-based architecture.
Step 3: Remove Deprecated APIs and Replace with Modern
APIs
Objective: Upgrade AX 2012 legacy functions to D365
equivalents.
Common replacements:
AX 2012 Deprecated
|
D365 Replacement
|
inventDim.inventDimId()
|
InventDim::findOrCreate()
|
ttsbegin/ttscommit in UI logic
|
Move logic to classes/services
|
RunBaseBatch
|
SysOperation Framework
|
Global::buf2Con()
|
ConPeek, ConIsEqual
|
Legacy AIF
|
Data Entities / OData / Custom services
|
RecordInsertList
|
Recordset-based inserts
|
Tasks:- Identify deprecated methods.
- Replace
with supported APIs.
- Validate
performance and correctness.
Output: Modern compliant APIs implemented.
Step 4: Resolve Metadata Conflicts
Objective: Fix conflicting element definitions
between AX 2012 and D365.
Tasks:
- Correct
duplicate table/field names.
- Fix
enumeration conflicts.
- Resolve
label conflicts (duplicate IDs).
- Merge
metadata changes from ISV layers.
- Ensure
correct model dependencies and reference libraries.
Output: Metadata structure aligned.
Step 5: Refactor Business Logic
Objective: Optimize and restructure old AX code to
D365 recommended architecture.
Tasks:
- Move
business logic from forms/tables to classes.
- Use
Chain-of-Command (CoC) instead of event handlers when possible.
- Encapsulate
logic in services where needed.
- Use
extension classes instead of modifying standard classes.
- Eliminate
hardcoding of values—use parameters.
Output: Clean, maintainable code structure.
Step 6: Validate Build & Compilation
Objective: Ensure code compiles and deploys
successfully.
Tasks:
- Perform
full compilation in Visual Studio.
- Resolve
build failures:
- Namespace
issues
- Missing
references
- Wrong
model dependencies
- Type
mismatches
- Perform
synchronization after build.
Output: Successful compile & sync.
Step 7: Unit Testing of Refactored Code
Objective: Verify correctness after refactoring.
Tasks:
- Run
automated tests if available.
- Manually
test critical business logic.
- Verify
outputs match AX 2012 behavior.
- Validate
error handling and exceptions.
Output: Unit test approval.
Step 8: Code Quality Review
Objective: Ensure standards and performance
compliance.
Tasks:
- Static
code analysis using Best Practice Checker.
- Fix
issues related to:
- Select
statements without where clauses
- Long
transactions
- Missing
exception handling
- Deprecated
APIs
- Hardcoded
values
- Peer
review by senior developer or architect.
Output: Code quality approved.
⏳ Average Timeline for Phase 4
|
Task
|
Duration
|
|
Conflict analysis
|
3–7 days
|
|
Overlayering removal
|
5–10 days
|
|
API replacement
|
5–12 days
|
|
Metadata conflict resolution
|
3–7 days
|
|
Code refactoring
|
10–20 days
|
|
Build validations
|
3–5 days
|
|
Unit testing
|
5–10 days
|
|
Code review
|
3–5 days
|
Task Duration
Conflict analysis 3–7 days
Overlayering removal 5–10 days
API replacement 5–12 days
Metadata conflict resolution 3–7 days
Code refactoring 10–20 days
Build validations 3–5 days
Unit testing 5–10 days
Code review 3–5 days
Total Estimated Duration:
➡️
30–60 days depending on customization volume.
⚠️ Common Challenges in Phase 4
1. Overlayering Cannot Be Converted Easily
- Heavy
customizations in SYS/SYP layers
- Standard
logic replaced instead of extended
- ISV
solutions not fully extension-enabled
Solution: Use CoC, redesign logic into new classes,
coordinate with ISV vendor.
2. Deprecated Features Not Supported in D365
Examples:
- AIF
Services → must replace with Data Entities
- SSRS
complex DP classes → need redesign
- Forms
with ActiveX controls → remove/convert
Solution: Use modern service framework or UI
patterns.
3. Model Dependency Conflicts
- Wrong
reference models cause build failures
- Missing
ISV models in correct layers
Solution: Correct model mapping and dependency
settings.
4. Performance Issues After Refactor
- Inefficient
conversions of queries
- Table
extensions causing join complexity
Solution: Review SQL traces, optimize queries.
5. Lack of Documentation for Old Custom Code
- Hard
to analyze intent or logic origin
Solution: Reverse engineer with:
- Trace
parser
- Debugging
old AX 2012 code
- Interviewing
business users
Below are realistic sample code refactoring examples
(Before vs After) based on common upgrade scenarios from AX 2012 →
Dynamics 365 Finance and Operations, showing how to move from overlayering
and deprecated patterns to extensions, CoC, services, and best
practices.
✅ Example 1: Overlayered Method
Replaced with Chain-of-Command
AX 2012 (Before – Overlayering)
public void posted()
{
super();
// Custom logic directly in standard method
if (this.Amount > 10000)
{
error("Amount exceeds approval limit.");
}
}
D365FO (After – Chain of Command)
[ExtensionOf(SalesTable)]
final class SalesTable_Extension
{
public void
posted()
{
next posted();
// Call base method first
if
(this.Amount > 10000)
{
throw
error("Amount exceeds approval limit.");
}
}
}
✅ Example 2: Deprecated
RunBaseBatch → SysOperation Framework
AX 2012 (Before – RunBaseBatch)
class MyBatchProcess extends RunBaseBatch
{
public void run()
{
super();
info("Processing completed.");
}
}
D365FO (After – SysOperation Framework)
Contract Class:
[DataContract]
class MyBatchProcessContract
{
}
Service Class:
class MyBatchProcessService
{
public void
process(MyBatchProcessContract _contract)
{
info("Processing completed.");
}
}
Controller Class:
class MyBatchProcessController extends SysOperationServiceController
{
public static void
main(Args _args)
{
SysOperationServiceController controller =
new
SysOperationServiceController(
classStr(MyBatchProcessService),
methodStr(MyBatchProcessService, process),
null);
controller.startOperation();
}
}
✅ Example 3: Business Logic Moved
out of Form into a Class
AX 2012 (Before – Logic inside Form Control Event)
void clicked()
{
super();
if
(SalesTable.SalesStatus == SalesStatus::Backorder)
{
error("Cannot confirm order in Backorder status.");
}
}
D365FO (After – Logic moved to a class & used via
CoC)
Logic in separate class:
class SalesOrderValidation
{
public static void
validateConfirm(SalesTable _salesTable)
{
if
(_salesTable.SalesStatus == SalesStatus::Backorder)
{
throw
error("Cannot confirm order in Backorder status.");
}
}
}
CoC extension for posting logic:
[ExtensionOf(SalesFormLetter_Confirm)]
final class SalesFormLetter_Confirm_Extension
{
public void run()
{
SalesOrderValidation::validateConfirm(salesTable);
next run();
}
}
✅ Example 4: Query Refactoring –
Select Statements
AX 2012 (Before – Inefficient select)
select firstOnly SalesTable
where
SalesTable.SalesId == _salesId;
D365FO (After – Using Query with CrossCompany option)
SalesTable salesTable;
select firstOnly crossCompany salesTable
where salesTable.SalesId
== _salesId;
(D365 requires explicit crossCompany if needed; also
recommended to use classes instead of inline selects for complex queries.)
✅ Example 5: File Upload Logic
Converted to D365FO Approaches
AX 2012 (Before – Using WinAPI)
FileName filename =
WinAPI::getOpenFileNameDialog("Select a file");
D365FO (After – Using FileUpload control)
Form uses FileUpload control, logic in a class:
public void processFile()
{
FileUploadTemporaryStorageResult result =
fileUploadControl.getFileUploadResult();
if (result
&& result.getUploadStatus())
{
// process
file
}
}
✅ Example 6: Conversion of
buf2Con / con2Buf Deprecated Functions
AX 2012 (Before – Deprecated)
container c = Global::buf2Con(custTable);
D365FO (After – Using Record and Con APIs)
container c;
c += custTable.AccountNum;
c += custTable.Currency;
Or using serialization:
container c =
FormJsonSerializer::serializeRecord(custTable);
✅ Example 7: AIF Document
Services → Data Entities
AX 2012 (Before – AIF Service Call)
AxdSalesOrder axdSalesOrder = new AxdSalesOrder();
axdSalesOrder.create(salesOrder);
D365FO (After – Data Entity or OData Service)
SalesOrderService s = SalesOrderService::construct();
s.createSalesOrder(salesOrderContract);
Or via OData client (external system).
✅ Example 8: Moving Hardcoded
Values to Parameters Table
AX 2012 (Before – Hardcoding in code)
if (custTable.PaymentTerms == 'NET30')
{
// logic
}
D365FO (After – Parameterized)
CustParameters custParameters = CustParameters::find();
if (custTable.PaymentTerms ==
custParameters.DefaultPaymentTerms)
{
// logic
}