Module microsoft.dynamics365.finance

edotco/microsoft.dynamics365.finance
Overview
The Microsoft Dynamics 365 Finance connector provides Ballerina with the capability to access Microsoft Dynamics 365 Finance and Operations OData REST API for data entities including customers, vendors, products, and financial data. This includes employee vendor management, expense claim processing, and payment confirmation tracking.
Setup guide
To use the Microsoft Dynamics 365 Finance connector, you need to have access to a Microsoft Dynamics 365 Finance environment with appropriate permissions.
Prerequisites
- Access to Microsoft Dynamics 365 Finance environment
- Valid authentication token (Bearer token)
- Appropriate permissions for the entities you want to access
Configuration
import ballerinax/microsoft.dynamics365.finance as d365finance; d365finance:ConnectionConfig config = { auth: { token: "<your-bearer-token>" } }; d365finance:Client d365Client = check new (config, "https://your-org.cloud.onebox.dynamics.com/data");
Quickstart
This guide demonstrates how to use the Microsoft Dynamics 365 Finance connector to perform basic operations.
Example: Create Employee Vendor
import ballerinax/microsoft.dynamics365.finance as d365finance; import ballerina/io; public function main() returns error? { d365finance:ConnectionConfig config = { auth: { token: "<your-bearer-token>" } }; d365finance:Client d365Client = check new (config, "https://your-org.cloud.onebox.dynamics.com/data"); // Create an employee vendor d365finance:EmployeeVendor employeeVendor = { dataAreaId: "usmf", VendorAccount: "P000219", FirstName: "Mimmie Melissa", LastName: "Binti Mohmad Haiyon", EmailAddress: "mimmiemelissa@edotcogroup.com", Language: "en-MY", CountryRegionId: "MYS", Currency: "MYR", Entity: "ECGR", CostCenter: "SS0400", EmployeeId: "11214", VendorType: "Person", IsEnabled: true }; d365finance:EmployeeVendor result = check d365Client->createEmployeeVendor(employeeVendor); io:println("Employee vendor created: ", result); }
Examples
The microsoft.dynamics365.finance
connector provides practical examples illustrating usage in various scenarios:
1. Employee Vendor Management
// Create Employee Vendor d365finance:EmployeeVendor employeeVendor = { dataAreaId: "usmf", VendorAccount: "P000219", FirstName: "John", LastName: "Doe", EmailAddress: "john.doe@company.com", Language: "en-US", CountryRegionId: "USA", Currency: "USD", Entity: "USMF", CostCenter: "CC001", EmployeeId: "EMP001", VendorType: "Person", IsEnabled: true }; d365finance:EmployeeVendor createdVendor = check d365Client->createEmployeeVendor(employeeVendor);
2. Update Employee Profile Cost Center
// Update employee profile cost center d365finance:EmployeeProfile profileUpdate = { CostCenter: "SS0500" }; d365finance:EmployeeProfile updatedProfile = check d365Client->updateEmployeeProfile("user123", profileUpdate);
3. Create Concur Claim Journal
// Create expense claim journal d365finance:ConcurClaimJournal claimJournal = { dataAreaId: "usmf", VendorId: "P000219", TransactionDate: "2024-02-21", AccountType: "Vendor", AccountNumber: "P000219", InvoiceReportKey: "76318", DocumentDate: "2023-10-18", TextReportName: "ETAP Workshop in Malaysia", AmountDebit: 20556.54, AmountCredit: 17996.54, ExchangeRate: 1.0, DocumentNumber: "76318", ConcurEmployeeName: "Hasan, Md. Mahmudul" }; d365finance:ConcurClaimJournal createdJournal = check d365Client->createClaimJournal(claimJournal);
4. Get Payment Confirmations
// Get payment confirmations with filter d365finance:GetPaymentConfirmationsQueries queries = { filter: "PaymentStatus eq 'Confirmed'", top: 50 }; d365finance:PaymentConfirmationsCollection confirmations = check d365Client->getPaymentConfirmations(queries = queries); // Get specific payment confirmation d365finance:PaymentConfirmation confirmation = check d365Client->getPaymentConfirmation("usmf", "PAY001");
5. Working with Existing APIs
// Get customers with cross-company query d365finance:GetCustomersV3FieldListCrossCompanyGbsiUssiQueries customerQueries = { crossCompany: "true", filter: "(dataAreaId eq 'USSI' or dataAreaId eq 'GBSI')", selectFields: "dataAreaId,CustomerAccount,OrganizationName" }; d365finance:CustomersV3Collection customers = check d365Client->getCustomersV3FieldListCrossCompanyGbsiUssi(queries = customerQueries); // Get vendors d365finance:GetVendorsV2CrossCompanyAllQueries vendorQueries = { crossCompany: "true", top: 100 }; d365finance:VendorsV2Collection vendors = check d365Client->getVendorsV2CrossCompanyAll(queries = vendorQueries);
Data Mappings
The connector supports the following key data mappings for employee vendor creation:
Field | Source | Target Field | Notes |
---|---|---|---|
Employee ID | User Administration | Phonetic first | Custom field mapping |
First Name | User Administration | First name | Direct mapping |
Last Name | User Administration | Last name | Direct mapping |
Email Address | User Administration | Email address | Both System Admin and Accounts Payable |
Language | User Administration | Language | Default language setting |
Country/Region | User Administration | Country/region | Location information |
Currency | User Administration | Currency | Reimbursement currency |
Entity | User Administration | Entity | Organization entity |
Cost Center | User Administration | Cost Center | Direct mapping |
Division | User Administration | Initials | Custom field mapping |
Department | User Administration | Known As | Custom field mapping |
Job Grade | User Administration | Professional suffix | Custom field mapping |
Active Status | User Administration | Enabled | System Administration access |