Skip to main content

Actions

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

ClientPurpose
ClientProvides access to Microsoft Dynamics 365 Finance Procurement entities (delivery terms, discount rates, intent letters, and vendor invoice declarations) via OData.

Client

Provides access to Microsoft Dynamics 365 Finance Procurement entities (delivery terms, discount rates, intent letters, and vendor invoice declarations) via OData.

Configuration

FieldTypeDefaultDescription
authOAuth2ClientCredentialsGrantConfigRequiredOAuth2 client credentials configuration containing tokenUrl, clientId, clientSecret, and scopes for authenticating against Microsoft Entra ID.
httpVersionhttp:HttpVersionhttp:HTTP_2_0HTTP protocol version to use for outbound requests.
http1Settingshttp:ClientHttp1Settings{}Configurations related to the HTTP/1.x protocol.
secureSockethttp:ClientSecureSocket?()SSL/TLS configuration for secure connections.
proxyhttp:ProxyConfig?()HTTP proxy server configuration.

Initializing the client

import ballerinax/microsoft.dynamics365.finance.procurement;

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

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

Operations

Delivery Terms

listDeliveryTerms

Lists DeliveryTerm records, with optional OData query support.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoOptional HTTP headers to include in the request.
queriesListDeliveryTermsQueriesNoOData query options: $skip, $top, $filter, $orderby, $expand, cross-company, $count, $select.

Returns: DeliveryTermsCollection|error

Sample code:

procurement:DeliveryTermsCollection result = check fo->listDeliveryTerms(
queries = {
filter: "FreightChargeTerms eq 'Prepaid'",
orderby: "TermsCode",
top: 10
}
);
createDeliveryTerms

Creates a new DeliveryTerm.

Parameters:

NameTypeRequiredDescription
payloadDeliveryTermYesThe DeliveryTerm record to create.
headersmap<string|string[]>NoOptional HTTP headers to include in the request.

Returns: DeliveryTerm|error

Sample code:

procurement:DeliveryTerm payload = {
dataAreaId: "USMF",
termsCode: "NET30",
termsDescription: "Net 30 days",
isCashOnDelivery: "No",
freightChargeTerms: "Prepaid",
portMandatory: "No",
goodsInTransitControl: "No"
};
procurement:DeliveryTerm result = check fo->createDeliveryTerms(payload);
getDeliveryTerms

Retrieves a single DeliveryTerm by its key.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier, e.g. "USMF".
termsCodestringYesThe terms code key field, e.g. "NET30".
headersmap<string|string[]>NoOptional HTTP headers to include in the request.
queriesGetDeliveryTermsQueriesNoOData query options: $expand, $select.

Returns: DeliveryTerm|error

Sample code:

procurement:DeliveryTerm result = check fo->getDeliveryTerms(
"USMF",
"NET30",
queries = {
'select: "TermsCode,TermsDescription,FreightChargeTerms"
}
);
deleteDeliveryTerms

Deletes a DeliveryTerm by its key.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier, e.g. "USMF".
termsCodestringYesThe terms code key field, e.g. "NET30".
headersDeleteDeliveryTermsHeadersNoOptional headers, including ifMatch (ETag for optimistic concurrency).

Returns: error?

Sample code:

check fo->deleteDeliveryTerms("USMF", "NET30");
updateDeliveryTerms

Updates an existing DeliveryTerm.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier, e.g. "USMF".
termsCodestringYesThe terms code key field, e.g. "NET30".
payloadDeliveryTermYesThe fields to update.
headersUpdateDeliveryTermsHeadersNoOptional headers, including ifMatch (ETag for optimistic concurrency).

Returns: DeliveryTerm|error

Sample code:

procurement:DeliveryTerm payload = {
termsDescription: "Net 30 days - revised"
};
procurement:DeliveryTerm result = check fo->updateDeliveryTerms("USMF", "NET30", payload);

Discount Rates

listDiscountRates

Lists DiscountRate records, with optional OData query support.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoOptional HTTP headers to include in the request.
queriesListDiscountRatesQueriesNoOData query options: $skip, $top, $filter, $orderby, $expand, cross-company, $count, $select.

Returns: DiscountRatesCollection|error

Sample code:

procurement:DiscountRatesCollection result = check fo->listDiscountRates(
queries = {
filter: "MarketDiscountRatePercentage gt 0",
orderby: "StartDate desc",
crossCompany: true
}
);
createDiscountRates

Creates a new DiscountRate.

Parameters:

NameTypeRequiredDescription
payloadDiscountRateYesThe DiscountRate record to create.
headersmap<string|string[]>NoOptional HTTP headers to include in the request.

Returns: DiscountRate|error

Sample code:

procurement:DiscountRate payload = {
dataAreaId: "USMF",
startDate: "2026-01-01",
marketDiscountRatePercentage: 2.5
};
procurement:DiscountRate result = check fo->createDiscountRates(payload);
getDiscountRates

Retrieves a single DiscountRate by its key.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier, e.g. "USMF".
startDatestringYesThe start date key field, e.g. "2026-01-01".
headersmap<string|string[]>NoOptional HTTP headers to include in the request.
queriesGetDiscountRatesQueriesNoOData query options: $expand, $select.

Returns: DiscountRate|error

Sample code:

procurement:DiscountRate result = check fo->getDiscountRates("USMF", "2026-01-01");
deleteDiscountRates

Deletes a DiscountRate by its key.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier, e.g. "USMF".
startDatestringYesThe start date key field, e.g. "2026-01-01".
headersDeleteDiscountRatesHeadersNoOptional headers, including ifMatch (ETag for optimistic concurrency).

Returns: error?

Sample code:

check fo->deleteDiscountRates("USMF", "2026-01-01");
updateDiscountRates

Updates an existing DiscountRate.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier, e.g. "USMF".
startDatestringYesThe start date key field, e.g. "2026-01-01".
payloadDiscountRateYesThe fields to update.
headersUpdateDiscountRatesHeadersNoOptional headers, including ifMatch (ETag for optimistic concurrency).

Returns: DiscountRate|error

Sample code:

procurement:DiscountRate payload = {
marketDiscountRatePercentage: 3.0
};
procurement:DiscountRate result = check fo->updateDiscountRates("USMF", "2026-01-01", payload);

Intent Letters

listIntentLetters

Lists IntentLetter records, with optional OData query support.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoOptional HTTP headers to include in the request.
queriesListIntentLettersQueriesNoOData query options: $skip, $top, $filter, $orderby, $expand, cross-company, $count, $select.

Returns: IntentLettersCollection|error

Sample code:

procurement:IntentLettersCollection result = check fo->listIntentLetters(
queries = {
filter: "Status eq 'Open' and VendAccount eq 'V-1002'",
orderby: "IntentLetterDate desc",
top: 20
}
);
createIntentLetters

Creates a new IntentLetter.

Parameters:

NameTypeRequiredDescription
payloadIntentLetterYesThe IntentLetter record to create.
headersmap<string|string[]>NoOptional HTTP headers to include in the request.

Returns: IntentLetter|error

Sample code:

procurement:IntentLetter payload = {
dataAreaId: "ITMF",
intentLetterId: "IL-2026-001",
vendAccount: "V-1002",
vendName: "Rossi Forniture Srl",
intentLetterType: "Period",
purchaseType: "Purchase",
fromDate: "2026-01-01",
toDate: "2026-12-31",
intentLetterAmountMST: 50000.00,
intentLetterYear: 2026,
status: "Open"
};
procurement:IntentLetter result = check fo->createIntentLetters(payload);
getIntentLetters

Retrieves a single IntentLetter by its key.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier, e.g. "ITMF".
intentLetterIdstringYesThe intent letter id key field, e.g. "IL-2026-001".
headersmap<string|string[]>NoOptional HTTP headers to include in the request.
queriesGetIntentLettersQueriesNoOData query options: $expand, $select.

Returns: IntentLetter|error

Sample code:

procurement:IntentLetter result = check fo->getIntentLetters(
"ITMF",
"IL-2026-001",
queries = {
'select: "IntentLetterId,Status,IntentLetterAmountMST,ToDate"
}
);
deleteIntentLetters

Deletes an IntentLetter by its key.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier, e.g. "ITMF".
intentLetterIdstringYesThe intent letter id key field, e.g. "IL-2026-001".
headersDeleteIntentLettersHeadersNoOptional headers, including ifMatch (ETag for optimistic concurrency).

Returns: error?

Sample code:

check fo->deleteIntentLetters("ITMF", "IL-2026-001");
updateIntentLetters

Updates an existing IntentLetter.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier, e.g. "ITMF".
intentLetterIdstringYesThe intent letter id key field, e.g. "IL-2026-001".
payloadIntentLetterYesThe fields to update.
headersUpdateIntentLettersHeadersNoOptional headers, including ifMatch (ETag for optimistic concurrency).

Returns: IntentLetter|error

Sample code:

procurement:IntentLetter payload = {
status: "Closed",
closedDate: "2026-12-31",
closingNotes: "Fully utilized within validity period"
};
procurement:IntentLetter result = check fo->updateIntentLetters("ITMF", "IL-2026-001", payload);

Vendor Invoice Declarations

listVendorInvoiceDeclarations

Lists VendorInvoiceDeclaration records, with optional OData query support.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoOptional HTTP headers to include in the request.
queriesListVendorInvoiceDeclarationsQueriesNoOData query options: $skip, $top, $filter, $orderby, $expand, cross-company, $count, $select.

Returns: VendorInvoiceDeclarationsCollection|error

Sample code:

procurement:VendorInvoiceDeclarationsCollection result = check fo->listVendorInvoiceDeclarations(
queries = {
filter: "RecordType eq 'LS'",
'select: "InvoiceDeclarationId,Description,ReportingCode"
}
);
createVendorInvoiceDeclarations

Creates a new VendorInvoiceDeclaration.

Parameters:

NameTypeRequiredDescription
payloadVendorInvoiceDeclarationYesThe VendorInvoiceDeclaration record to create.
headersmap<string|string[]>NoOptional HTTP headers to include in the request.

Returns: VendorInvoiceDeclaration|error

Sample code:

procurement:VendorInvoiceDeclaration payload = {
dataAreaId: "ISMF",
invoiceDeclarationId: "DECL-2026-01",
description: "Monthly vendor invoice declaration",
recordType: "LS",
reportingCode: "RC-100"
};
procurement:VendorInvoiceDeclaration result = check fo->createVendorInvoiceDeclarations(payload);
getVendorInvoiceDeclarations

Retrieves a single VendorInvoiceDeclaration by its key.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier, e.g. "ISMF".
invoiceDeclarationIdstringYesThe invoice declaration id key field, e.g. "DECL-2026-01".
headersmap<string|string[]>NoOptional HTTP headers to include in the request.
queriesGetVendorInvoiceDeclarationsQueriesNoOData query options: $expand, $select.

Returns: VendorInvoiceDeclaration|error

Sample code:

procurement:VendorInvoiceDeclaration result = check fo->getVendorInvoiceDeclarations("ISMF", "DECL-2026-01");
deleteVendorInvoiceDeclarations

Deletes a VendorInvoiceDeclaration by its key.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier, e.g. "ISMF".
invoiceDeclarationIdstringYesThe invoice declaration id key field, e.g. "DECL-2026-01".
headersDeleteVendorInvoiceDeclarationsHeadersNoOptional headers, including ifMatch (ETag for optimistic concurrency).

Returns: error?

Sample code:

check fo->deleteVendorInvoiceDeclarations("ISMF", "DECL-2026-01");
updateVendorInvoiceDeclarations

Updates an existing VendorInvoiceDeclaration.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier, e.g. "ISMF".
invoiceDeclarationIdstringYesThe invoice declaration id key field, e.g. "DECL-2026-01".
payloadVendorInvoiceDeclarationYesThe fields to update.
headersUpdateVendorInvoiceDeclarationsHeadersNoOptional headers, including ifMatch (ETag for optimistic concurrency).

Returns: VendorInvoiceDeclaration|error

Sample code:

procurement:VendorInvoiceDeclaration payload = {
reportingCode: "RC-101"
};
procurement:VendorInvoiceDeclaration result = check fo->updateVendorInvoiceDeclarations("ISMF", "DECL-2026-01", payload);