Scenario: Run foreign currency revaluation
Goal. At period end, your close tool or scheduler revalues the foreign-currency balances of a legal entity at the exchange rate of a date: the open customer transactions, the open vendor transactions and the general ledger balances. Lattice runs the same standard revaluation the D365 pages run, posts the unrealized exchange adjustments, and tells you whether anything was posted and in which voucher.
When to use. Month-end and year-end close, run from outside D365 or on a schedule. Run the three revaluations as separate requests, in the order your close checklist needs. Entries that are not exchange adjustments go through General and intercompany journals.
Prerequisites
- Security. All three operations need privilege
MGCLatticeGeneralLedgerServiceMaintain, in dutyMGCLatticeIntegrationServiceOperationsDuty(integration operator and administrator roles). Without it D365 refuses the call with HTTP 403. - D365 setup in the legal entity.
- Exchange rates for the revaluation date in the ledger's exchange rate type (General ledger >
Currencies > Currency exchange rates). USMF's
Defaulttype has open-ended USD to EUR and USD to CAD rates. - Unrealized gain and loss accounts: for customers and vendors on General ledger > Currencies >
Currency revaluation accounts; for the ledger on General ledger > Ledger setup > Ledger
(Accounts for currency revaluation). USMF's ledger uses
801600Currency Adjustment Profits - Unrealized. - The main accounts you revalue are set up for foreign currency revaluation, and the posting period of the revaluation date is open.
- Exchange rates for the revaluation date in the ledger's exchange rate type (General ledger >
Currencies > Currency exchange rates). USMF's
- Lattice. A valid license (a never-registered environment is allowed through; an adverse verdict
refuses the run with
LicenseNotValid). The revaluation request takes no external keys and needs no Lattice parameters.
Steps
The three operations are on MGCLatticeCurrencyRevaluationService in service group
MGCLatticeGeneralLedgerServiceGroup and share one request contract. Send a POST with an OAuth 2.0
bearer token and the request in _request (see Trial and day-one guide).
-
Revalue customer transactions.
runCustomerRevaluationrevalues the open customer transactions at the exchange rate ofRevaluationDate(default: today in the calling user's time zone), forCurrencyCodeor, when you leave it out, for every foreign currency. It uses the standard method, with the revaluation date as both the considered date and the date of the rate.POST https://<your-environment>/api/services/MGCLatticeGeneralLedgerServiceGroup/MGCLatticeCurrencyRevaluationService/runCustomerRevaluation{"_request": {"RequestId": "4d5e6f7a-8b9c-4d0e-9f1a-2b3c4d5e6f7a","LegalEntityId": "USMF","UserContext": "close-tool","RevaluationDate": "2026-10-31","CurrencyCode": "EUR"}}The customer and vendor runs have no period and no account range: do not send
FromDate,MainAccountFromIdorMainAccountToId, which are refused. -
Revalue vendor transactions. Send the same request, with a new
RequestId, torunVendorRevaluation:POST https://<your-environment>/api/services/MGCLatticeGeneralLedgerServiceGroup/MGCLatticeCurrencyRevaluationService/runVendorRevaluation -
Revalue the ledger.
runLedgerRevaluationrevalues the general ledger forCurrencyCode(or, when you leave it out, every currency posted to the ledger in the period), fromFromDatethroughRevaluationDate, optionally only for main accountsMainAccountFromIdthroughMainAccountToId.FromDatedefaults to the start of the fiscal year ofRevaluationDate; both dates must be in one fiscal year.POST https://<your-environment>/api/services/MGCLatticeGeneralLedgerServiceGroup/MGCLatticeCurrencyRevaluationService/runLedgerRevaluation{"_request": {"RequestId": "6f7a8b9c-0d1e-4f2a-8b3c-4d5e6f7a8b9c","LegalEntityId": "USMF","UserContext": "close-tool","RevaluationDate": "2026-10-31","CurrencyCode": "EUR","MainAccountFromId": "110110","MainAccountToId": "801600"}} -
Read the result. Every successful run answers
SuccesstrueandStatus3; what it posted is inDocumentId,PostedDocumentIdand the message:Outcome DocumentId/PostedDocumentIdMessage Customer or vendor adjustments posted The adjustment voucher "Customer (Vendor) foreign currency revaluation as of ... adjusted N transaction(s) in voucher ..." Customer or vendor: nothing to adjust Empty "... found nothing to adjust. Nothing was posted." Ledger adjustments posted The adjustment voucher "Ledger foreign currency revaluation for EUR from ... through ... was posted in voucher ..." Ledger: nothing to adjust Empty "Ledger foreign currency revaluation for ... found nothing to adjust. Nothing was posted." Ledger, no currency sent, no transactions in the period Empty "No ledger transactions were posted in any currency between ... and ..., so there is nothing to revalue." An empty
DocumentIdon a successful run is a normal result, not an error: there was nothing to revalue at that rate. UseDocumentId(not the message text, which is localized) to decide whether a voucher was posted.
Bulk variants runCustomerRevaluationBatch, runVendorRevaluationBatch and runLedgerRevaluationBatch
take a _requests list, for example one item per legal entity. Large runs can be queued with
submitAsyncOperation and polled with getAsyncOperationStatus (see
API reference, sections 19 and 21).
How to verify
- The response:
Successtrue,Status3, and, when adjustments were posted,DocumentId=PostedDocumentId= the voucher. - The customer adjustments: read
LatticeCustomerTransactionsfiltered onVoucher(the returned voucher) anddataAreaId, withcross-company=true; the rows haveTransactionTypeExchAdjustment. For vendors, readLatticeVendorTransactionsthe same way. - The ledger side of any run:
LatticeGeneralLedgerEntrieswith$filter=SubledgerVoucher eq '<voucher>' and LegalEntityId eq 'USMF'. - In D365: General ledger > Inquiries and reports > Voucher transactions for the voucher; the revaluation history on General ledger > Currencies > Foreign currency revaluation (ledger) and on the Foreign currency revaluation pages under Accounts receivable > Periodic tasks and Accounts payable > Periodic tasks.
- The call: System administration > Inquiries > Lattice > Services > Service call log, or
LatticeServiceCallLogsfiltered on yourRequestId.
When it goes wrong
A failed run answers Success false, Status 4, an ErrorCode and a generic Message; the reasons
are in Errors.
| ErrorCode | Typical cause (text in Errors) | What to do |
|---|---|---|
ValidationFailed (1) | No RequestId or unknown LegalEntityId; "FromDate, MainAccountFromId and MainAccountToId apply to runLedgerRevaluation only. ... does not accept them."; a ledger FromDate after RevaluationDate; "The ledger revaluation settings are not valid; see the errors for the reason." (for example dates in two fiscal years) | Correct the request and resend. |
BusinessRule (4) | The standard revaluation stopped: no exchange rate for the date, no revaluation accounts, a closed period | Fix the setup named in Errors, then resend. |
PreviewUnsupported (10) | PreviewMode true: revaluation has no preview | Send without PreviewMode. Nothing was run. |
TransientRuntime (6) | Infrastructure fault; IsRetryable true | Resend with the same RequestId. |
DuplicateRequest (7) | The RequestId was first used for another operation (for example the customer run's id sent to the vendor run) | Send a new RequestId for each run. |
LicenseNotValid (12) | The license verdict is adverse; IsRetryable true | Renew the license, then resend. |
Choosing the RequestId. A revaluation is a run, not a document: resending a RequestId that
succeeded returns the first result and does not run again, while a new RequestId runs a new revaluation.
Give each run (legal entity, operation, revaluation date) its own stable RequestId, and reuse it only when
you retry that same run. A failed run releases its RequestId, so you can resend it after fixing the cause.
Queued runs. A run submitted with submitAsyncOperation that fails while it runs lands in the
dead-letter queue (System administration > Inquiries > Lattice > Integration operations > Integration
operations console); see Integration operations.
Reference
- API reference: section 17 (Currency Revaluation Service), 19 and 21 (bulk and async)
- Endpoint payload specification:
MGCLatticeCurrencyRevaluationService - Data entity reference:
LatticeCustomerTransactions,LatticeVendorTransactions,LatticeGeneralLedgerEntries - Security model
- Post a journal exactly-once
- Integration operations