Skip to main content

Actions

The ballerinax/microsoft.dynamics365.finance.journalentry package exposes the following clients:

ClientPurpose
ClientProvides full CRUD access to Microsoft Dynamics 365 Finance journal entry entities — general journal batches, journal batch names, journal lines, project journal transactions, ledger journal lines, and ledger transaction settlements — via the Dynamics 365 Finance and Operations OData API.

Client

Provides full CRUD access to Microsoft Dynamics 365 Finance journal entry entities via the Dynamics 365 Finance and Operations OData API.

Configuration

FieldTypeDefaultDescription
authOAuth2ClientCredentialsGrantConfigRequiredOAuth2 client credentials grant configuration; provide tokenUrl, clientId, clientSecret, and scopes to authenticate with Microsoft Entra ID.
httpVersionhttp:HttpVersion"2.0"HTTP protocol version to use for outbound requests.
http1Settingshttp:ClientHttp1Settings{}HTTP/1.x client settings including keep-alive, chunking, and proxy configuration.
secureSockethttp:ClientSecureSocket()SSL/TLS configuration for secure connections.
proxyhttp:ProxyConfig()Proxy server configuration.

Initializing the client

import ballerinax/microsoft.dynamics365.finance.journalentry;

configurable string tokenUrl = ?;
configurable string clientId = ?;
configurable string clientSecret = ?;
configurable string serviceUrl = ?;

journalentry:Client fo = check new (
{
auth: {
tokenUrl,
clientId,
clientSecret
}
},
serviceUrl
);

Operations

Journal Lines

listJournalLines

Reads all general journal lines in the system.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesListJournalLinesQueriesNoOData query parameters: skip, top, filter, orderby, expand, crossCompany, count, 'select.

Returns: JournalLinesCollection|error

Sample code:

journalentry:JournalLinesCollection lines = check fo->listJournalLines(
queries = {
filter: "JournalBatchNumber eq 'JB-000123'",
top: 25,
orderby: "LineNumber asc"
}
);
createJournalLines

Creates a general journal line.

Parameters:

NameTypeRequiredDescription
payloadJournalLineYesThe journal line fields to create.
headersmap<string|string[]>NoAdditional HTTP request headers.

Returns: JournalLine|error

Sample code:

journalentry:JournalLine created = check fo->createJournalLines({
dataAreaId: "USMF",
journalBatchNumber: "JB-000123",
lineNumber: 1,
accountType: "Ledger",
accountDisplayValue: "110110",
debit: 1500.00,
credit: 0.00,
currency: "USD",
transactionDate: "2026-08-05",
description: "Office supplies accrual"
});
getJournalLines

Retrieves a specific general journal line identified by company, journal batch number, and line number.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
journalBatchNumberstringYesThe journal batch number key field.
lineNumberdecimalYesThe line number key field.
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesGetJournalLinesQueriesNoOData query parameters: expand, 'select.

Returns: JournalLine|error

Sample code:

journalentry:JournalLine line = check fo->getJournalLines(
"USMF",
"JB-000123",
1,
queries = {
'select: "AccountDisplayValue,Debit,Credit,TransactionDate"
}
);
deleteJournalLines

Deletes a specific general journal line.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
journalBatchNumberstringYesThe journal batch number key field.
lineNumberdecimalYesThe line number key field.
headersDeleteJournalLinesHeadersNoHTTP headers for this request; set ifMatch to send an If-Match ETag for optimistic concurrency control.

Returns: error?

Sample code:

check fo->deleteJournalLines(
"USMF",
"JB-000123",
1,
headers = {ifMatch: eTag}
);
updateJournalLines

Updates a specific general journal line.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
journalBatchNumberstringYesThe journal batch number key field.
lineNumberdecimalYesThe line number key field.
payloadJournalLineYesThe journal line fields to update.
headersUpdateJournalLinesHeadersNoHTTP headers for this request; set ifMatch to send an If-Match ETag for optimistic concurrency control.

Returns: JournalLine|error

Sample code:

journalentry:JournalLine updated = check fo->updateJournalLines(
"USMF",
"JB-000123",
1,
{debit: 1750.00, description: "Office supplies accrual - revised"},
headers = {ifMatch: eTag}
);

Journal Names

listJournalNames

Reads all journal names (journal batch templates) in the system.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesListJournalNamesQueriesNoOData query parameters: skip, top, filter, orderby, expand, crossCompany, count, 'select.

Returns: JournalNamesCollection|error

Sample code:

journalentry:JournalNamesCollection names = check fo->listJournalNames(
queries = {
filter: "Type eq 'Daily'",
crossCompany: true
}
);
createJournalNames

Creates a journal name.

Parameters:

NameTypeRequiredDescription
payloadJournalNameYesThe journal name fields to create.
headersmap<string|string[]>NoAdditional HTTP request headers.

Returns: JournalName|error

Sample code:

journalentry:JournalName created = check fo->createJournalNames({
dataAreaId: "USMF",
name: "GenJrn",
description: "General journal",
'type: "Daily",
currency: "USD",
postingLayer: "Current",
voucherSeriesCode: "GenJrn"
});
getJournalNames

Retrieves a specific journal name identified by company and name.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
namestringYesThe name key field.
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesGetJournalNamesQueriesNoOData query parameters: expand, 'select.

Returns: JournalName|error

Sample code:

journalentry:JournalName name = check fo->getJournalNames(
"USMF",
"GenJrn"
);
deleteJournalNames

Deletes a specific journal name.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
namestringYesThe name key field.
headersDeleteJournalNamesHeadersNoHTTP headers for this request; set ifMatch to send an If-Match ETag for optimistic concurrency control.

Returns: error?

Sample code:

check fo->deleteJournalNames(
"USMF",
"GenJrn",
headers = {ifMatch: eTag}
);
updateJournalNames

Updates a specific journal name.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
namestringYesThe name key field.
payloadJournalNameYesThe journal name fields to update.
headersUpdateJournalNamesHeadersNoHTTP headers for this request; set ifMatch to send an If-Match ETag for optimistic concurrency control.

Returns: JournalName|error

Sample code:

journalentry:JournalName updated = check fo->updateJournalNames(
"USMF",
"GenJrn",
{description: "General journal - accruals and reclasses"},
headers = {ifMatch: eTag}
);

Journal Tables

listJournalTables

Reads all general journal batch headers in the system.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesListJournalTablesQueriesNoOData query parameters: skip, top, filter, orderby, expand, crossCompany, count, 'select.

Returns: JournalTablesCollection|error

Sample code:

journalentry:JournalTablesCollection batches = check fo->listJournalTables(
queries = {
filter: "JournalName eq 'GenJrn' and Posted eq 'No'",
top: 50
}
);
createJournalTables

Creates a general journal batch header.

Parameters:

NameTypeRequiredDescription
payloadJournalTableYesThe journal batch fields to create.
headersmap<string|string[]>NoAdditional HTTP request headers.

Returns: JournalTable|error

Sample code:

journalentry:JournalTable created = check fo->createJournalTables({
dataAreaId: "USMF",
journalName: "GenJrn",
description: "August general ledger accrual batch",
txt: "Month-end accrual",
detailSummary: "Detail"
});
getJournalTables

Retrieves a specific general journal batch header identified by company and journal batch number.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
journalBatchNumberstringYesThe journal batch number key field.
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesGetJournalTablesQueriesNoOData query parameters: expand, 'select.

Returns: JournalTable|error

Sample code:

journalentry:JournalTable batch = check fo->getJournalTables(
"USMF",
"JB-000123",
queries = {
expand: "JournalLines"
}
);
deleteJournalTables

Deletes a specific general journal batch header.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
journalBatchNumberstringYesThe journal batch number key field.
headersDeleteJournalTablesHeadersNoHTTP headers for this request; set ifMatch to send an If-Match ETag for optimistic concurrency control.

Returns: error?

Sample code:

check fo->deleteJournalTables(
"USMF",
"JB-000123",
headers = {ifMatch: eTag}
);
updateJournalTables

Updates a specific general journal batch header.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
journalBatchNumberstringYesThe journal batch number key field.
payloadJournalTableYesThe journal batch fields to update.
headersUpdateJournalTablesHeadersNoHTTP headers for this request; set ifMatch to send an If-Match ETag for optimistic concurrency control.

Returns: JournalTable|error

Sample code:

journalentry:JournalTable updated = check fo->updateJournalTables(
"USMF",
"JB-000123",
{txt: "Month-end accrual - reviewed"},
headers = {ifMatch: eTag}
);

Journal Trans

listJournalTrans

Reads all project and subledger journal transaction lines in the system.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesListJournalTransQueriesNoOData query parameters: skip, top, filter, orderby, expand, crossCompany, count, 'select.

Returns: JournalTransCollection|error

Sample code:

journalentry:JournalTransCollection trans = check fo->listJournalTrans(
queries = {
filter: "ProjectID eq 'PRJ-1001'",
orderby: "LineNumber asc"
}
);
createJournalTrans

Creates a project or subledger journal transaction line.

Parameters:

NameTypeRequiredDescription
payloadJournalTransYesThe journal transaction fields to create.
headersmap<string|string[]>NoAdditional HTTP request headers.

Returns: JournalTrans|error

Sample code:

journalentry:JournalTrans created = check fo->createJournalTrans({
dataAreaId: "USMF",
journalId: "PJ-000045",
lineNumber: 1,
projectID: "PRJ-1001",
category: "Consulting",
hours: 8,
costPrice: 45.00,
salesPrice: 90.00,
currencyId: "USD",
description: "Consulting hours - week 32"
});
getJournalTrans

Retrieves a specific journal transaction line identified by company, line number, and journal ID.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
lineNumberdecimalYesThe line number key field.
journalIdstringYesThe journal id key field.
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesGetJournalTransQueriesNoOData query parameters: expand, 'select.

Returns: JournalTrans|error

Sample code:

journalentry:JournalTrans line = check fo->getJournalTrans(
"USMF",
1,
"PJ-000045"
);
deleteJournalTrans

Deletes a specific journal transaction line.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
lineNumberdecimalYesThe line number key field.
journalIdstringYesThe journal id key field.
headersDeleteJournalTransHeadersNoHTTP headers for this request; set ifMatch to send an If-Match ETag for optimistic concurrency control.

Returns: error?

Sample code:

check fo->deleteJournalTrans(
"USMF",
1,
"PJ-000045",
headers = {ifMatch: eTag}
);
updateJournalTrans

Updates a specific journal transaction line.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
lineNumberdecimalYesThe line number key field.
journalIdstringYesThe journal id key field.
payloadJournalTransYesThe journal transaction fields to update.
headersUpdateJournalTransHeadersNoHTTP headers for this request; set ifMatch to send an If-Match ETag for optimistic concurrency control.

Returns: JournalTrans|error

Sample code:

journalentry:JournalTrans updated = check fo->updateJournalTrans(
"USMF",
1,
"PJ-000045",
{hours: 7.5, salesPrice: 87.50},
headers = {ifMatch: eTag}
);

Ledger Journal Lines

listLedgerJournalLines

Reads all ledger journal voucher lines in the system.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesListLedgerJournalLinesQueriesNoOData query parameters: skip, top, filter, orderby, expand, crossCompany, count, 'select.

Returns: LedgerJournalLinesCollection|error

Sample code:

journalentry:LedgerJournalLinesCollection lines = check fo->listLedgerJournalLines(
queries = {
filter: "JournalBatchNumber eq 'LJ-000456'",
orderby: "LineNumber asc"
}
);
createLedgerJournalLines

Creates a ledger journal voucher line.

Parameters:

NameTypeRequiredDescription
payloadLedgerJournalLineYesThe ledger journal line fields to create.
headersmap<string|string[]>NoAdditional HTTP request headers.

Returns: LedgerJournalLine|error

Sample code:

journalentry:LedgerJournalLine created = check fo->createLedgerJournalLines({
dataAreaId: "USMF",
journalBatchNumber: "LJ-000456",
lineNumber: 1,
accountType: "Ledger",
accountNum: "110110",
currencyCode: "USD",
debitAmount: 2500.00,
creditAmount: 0.00,
text: "Utilities accrual",
transDate: "2026-08-05"
});
getLedgerJournalLines

Retrieves a specific ledger journal voucher line identified by company, journal batch number, and line number.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
journalBatchNumberstringYesThe journal batch number key field.
lineNumberdecimalYesThe line number key field.
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesGetLedgerJournalLinesQueriesNoOData query parameters: expand, 'select.

Returns: LedgerJournalLine|error

Sample code:

journalentry:LedgerJournalLine line = check fo->getLedgerJournalLines(
"USMF",
"LJ-000456",
1
);
deleteLedgerJournalLines

Deletes a specific ledger journal voucher line.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
journalBatchNumberstringYesThe journal batch number key field.
lineNumberdecimalYesThe line number key field.
headersDeleteLedgerJournalLinesHeadersNoHTTP headers for this request; set ifMatch to send an If-Match ETag for optimistic concurrency control.

Returns: error?

Sample code:

check fo->deleteLedgerJournalLines(
"USMF",
"LJ-000456",
1,
headers = {ifMatch: eTag}
);
updateLedgerJournalLines

Updates a specific ledger journal voucher line.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
journalBatchNumberstringYesThe journal batch number key field.
lineNumberdecimalYesThe line number key field.
payloadLedgerJournalLineYesThe ledger journal line fields to update.
headersUpdateLedgerJournalLinesHeadersNoHTTP headers for this request; set ifMatch to send an If-Match ETag for optimistic concurrency control.

Returns: LedgerJournalLine|error

Sample code:

journalentry:LedgerJournalLine updated = check fo->updateLedgerJournalLines(
"USMF",
"LJ-000456",
1,
{debitAmount: 2650.00, text: "Utilities accrual - revised"},
headers = {ifMatch: eTag}
);

Ledger Trans Settlements

listLedgerTransSettlements

Reads all ledger transaction settlement records in the system.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesListLedgerTransSettlementsQueriesNoOData query parameters: skip, top, filter, orderby, expand, crossCompany, count, 'select.

Returns: LedgerTransSettlementsCollection|error

Sample code:

journalentry:LedgerTransSettlementsCollection settlements = check fo->listLedgerTransSettlements(
queries = {
filter: "DocumentNumber eq 'INV-90441'"
}
);
createLedgerTransSettlements

Creates a ledger transaction settlement record.

Parameters:

NameTypeRequiredDescription
payloadLedgerTransSettlementYesThe ledger transaction settlement fields to create.
headersmap<string|string[]>NoAdditional HTTP request headers.

Returns: LedgerTransSettlement|error

Sample code:

journalentry:LedgerTransSettlement created = check fo->createLedgerTransSettlements({
ledger: 5637144576,
mainAccount: 5637177840,
transactionCurrencyAmount: 1000.00,
transactionCurrencyCode: "USD",
accountingDate: "2026-08-05",
documentNumber: "INV-90441",
postingType: "CustPayment",
text: "Customer payment settlement"
});
getLedgerTransSettlements

Retrieves a specific ledger transaction settlement record identified by its general journal account entry.

Parameters:

NameTypeRequiredDescription
generalJournalAccountEntryintYesThe general journal account entry key field.
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesGetLedgerTransSettlementsQueriesNoOData query parameters: expand, 'select.

Returns: LedgerTransSettlement|error

Sample code:

journalentry:LedgerTransSettlement settlement = check fo->getLedgerTransSettlements(5637289421);
deleteLedgerTransSettlements

Deletes a specific ledger transaction settlement record.

Parameters:

NameTypeRequiredDescription
generalJournalAccountEntryintYesThe general journal account entry key field.
headersDeleteLedgerTransSettlementsHeadersNoHTTP headers for this request; set ifMatch to send an If-Match ETag for optimistic concurrency control.

Returns: error?

Sample code:

check fo->deleteLedgerTransSettlements(
5637289421,
headers = {ifMatch: eTag}
);
updateLedgerTransSettlements

Updates a specific ledger transaction settlement record.

Parameters:

NameTypeRequiredDescription
generalJournalAccountEntryintYesThe general journal account entry key field.
payloadLedgerTransSettlementYesThe ledger transaction settlement fields to update.
headersUpdateLedgerTransSettlementsHeadersNoHTTP headers for this request; set ifMatch to send an If-Match ETag for optimistic concurrency control.

Returns: LedgerTransSettlement|error

Sample code:

journalentry:LedgerTransSettlement updated = check fo->updateLedgerTransSettlements(
5637289421,
{text: "Customer payment settlement - confirmed"},
headers = {ifMatch: eTag}
);

Ledger Trans Settlements V2

listLedgerTransSettlementsV2

Reads all ledger transaction settlement records (V2) in the system, including settlement status and open-amount fields.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesListLedgerTransSettlementsV2QueriesNoOData query parameters: skip, top, filter, orderby, expand, crossCompany, count, 'select.

Returns: LedgerTransSettlementsV2Collection|error

Sample code:

journalentry:LedgerTransSettlementsV2Collection settlements = check fo->listLedgerTransSettlementsV2(
queries = {
filter: "SettleStatus eq 'Unsettled'"
}
);
createLedgerTransSettlementsV2

Creates a ledger transaction settlement record (V2).

Parameters:

NameTypeRequiredDescription
payloadLedgerTransSettlementV2YesThe ledger transaction settlement fields to create.
headersmap<string|string[]>NoAdditional HTTP request headers.

Returns: LedgerTransSettlementV2|error

Sample code:

journalentry:LedgerTransSettlementV2 created = check fo->createLedgerTransSettlementsV2({
ledger: 5637144576,
mainAccount: 5637177840,
transactionCurrencyAmount: 750.00,
transactionCurrencyCode: "USD",
accountingDate: "2026-08-05",
documentNumber: "INV-90512",
postingType: "VendPayment",
settleStatus: "Unsettled",
text: "Vendor payment pending settlement"
});
getLedgerTransSettlementsV2

Retrieves a specific ledger transaction settlement record (V2) identified by its general journal account entry.

Parameters:

NameTypeRequiredDescription
generalJournalAccountEntryintYesThe general journal account entry key field.
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesGetLedgerTransSettlementsV2QueriesNoOData query parameters: expand, 'select.

Returns: LedgerTransSettlementV2|error

Sample code:

journalentry:LedgerTransSettlementV2 settlement = check fo->getLedgerTransSettlementsV2(5637291178);
deleteLedgerTransSettlementsV2

Deletes a specific ledger transaction settlement record (V2).

Parameters:

NameTypeRequiredDescription
generalJournalAccountEntryintYesThe general journal account entry key field.
headersDeleteLedgerTransSettlementsV2HeadersNoHTTP headers for this request; set ifMatch to send an If-Match ETag for optimistic concurrency control.

Returns: error?

Sample code:

check fo->deleteLedgerTransSettlementsV2(
5637291178,
headers = {ifMatch: eTag}
);
updateLedgerTransSettlementsV2

Updates a specific ledger transaction settlement record (V2).

Parameters:

NameTypeRequiredDescription
generalJournalAccountEntryintYesThe general journal account entry key field.
payloadLedgerTransSettlementV2YesThe ledger transaction settlement fields to update.
headersUpdateLedgerTransSettlementsV2HeadersNoHTTP headers for this request; set ifMatch to send an If-Match ETag for optimistic concurrency control.

Returns: LedgerTransSettlementV2|error

Sample code:

journalentry:LedgerTransSettlementV2 updated = check fo->updateLedgerTransSettlementsV2(
5637291178,
{settleStatus: "Settled", settleDate: "2026-08-05"},
headers = {ifMatch: eTag}
);