Overview
Energy CMMS supports integration with Microsoft Dynamics 365 for synchronizing financial data, purchase orders, and asset information between systems.Integration Architecture
Configuration
Environment Variables
Add these settings to yoursettings.py or environment configuration:
Authentication Setup
user_impersonationIntegration Modules
Purchase Order Sync
Sync purchase orders and requisitions from Energy CMMS to Dynamics 365:presupuestos/dynamics.py
Asset Information Sync
Export asset data to Dynamics 365:activos/dynamics.py
Webhook Configuration
Receive Updates from Dynamics 365
Configure webhooks to receive real-time updates:core/views.py
Celery Tasks for Background Sync
activos/tasks.py
Data Mapping
Asset Fields
| Energy CMMS Field | Dynamics 365 Field | Type |
|---|---|---|
codigo_interno | msdyn_assetnumber | String |
nombre | msdyn_name | String |
numero_de_serie | msdyn_serialid | String |
valor_adquisicion | msdyn_acquisitioncost | Decimal |
valor_libros | msdyn_currentbookvalue | Decimal |
fecha_adquisicion | msdyn_acquisitiondate | DateTime |
Purchase Order Fields
| Energy CMMS Field | Dynamics 365 Field | Type |
|---|---|---|
numero_requisicion | name | String |
justificacion | description | String |
total | totalamount | Decimal |
estado | statuscode | OptionSet |
fecha_creacion | createdon | DateTime |
Troubleshooting
Authentication failed
Authentication failed
Error:
401 UnauthorizedSolutions:- Verify client ID and secret are correct
- Check tenant ID matches your organization
- Ensure API permissions are granted
- Regenerate access token if expired
API request timeout
API request timeout
Error:
RequestTimeout or 504 Gateway TimeoutSolutions:- Increase timeout in settings
- Use async Celery tasks for large operations
- Implement retry logic with exponential backoff
Duplicate records created
Duplicate records created
Solutions:
- Implement idempotency keys
- Check for existing records before creating
- Use unique identifiers (e.g.,
codigo_interno)
Best Practices
Use Batch Operations
When syncing multiple records, use Dynamics 365 batch API to reduce API calls
Implement Webhooks
Use webhooks for real-time sync instead of polling for changes
Cache Tokens
Cache OAuth tokens to avoid repeated authentication requests
Error Handling
Implement comprehensive error handling and logging for troubleshooting
Related Resources
Celery Tasks
Learn about background task processing