Skip to main content

Actions

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

ClientPurpose
ClientProvides full CRUD access to Microsoft Dynamics 365 Finance customer electronic addresses, postal addresses, payment methods, payment journal headers and lines, and posting profiles via the Dynamics 365 Finance and Operations OData API.

Client

Provides full CRUD access to Microsoft Dynamics 365 Finance customer electronic addresses, postal addresses, payment methods, payment journal headers and lines, and posting profiles via the Dynamics 365 Finance and Operations OData API.

Configuration

FieldTypeDefaultDescription
authOAuth2ClientCredentialsGrantConfigRequiredOAuth2 client credentials grant configuration used to authenticate with Microsoft Entra ID (Azure AD): tokenUrl, clientId, clientSecret, and optional scopes.
httpVersionhttp:HttpVersion2.0HTTP 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.customeraccount;

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

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

Operations

Customer electronic addresses

listCustomerElectronicAddresses

Reads all customer electronic addresses (phone, email, URL, and other contact methods).

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoHeaders to be sent with the request.
queriesListCustomerElectronicAddressesQueriesNoOData query parameters: $skip, $top, $filter, $orderby, $expand, cross-company, $count, $select.

Returns: customeraccount:CustomerElectronicAddressesCollection|error

Sample code:

customeraccount:CustomerElectronicAddressesCollection addresses = check fo->listCustomerElectronicAddresses(
queries = {
filter: "CustomerAccount eq 'CUST-3001' and Type eq 'Email'",
top: 20,
'select: "CustomerAccount,ElectronicAddressId,Type,Locator,IsPrimary"
}
);
createCustomerElectronicAddresses

Creates a customer electronic address.

Parameters:

NameTypeRequiredDescription
payloadCustomerElectronicAddressYesThe customer electronic address to create.
headersmap<string|string[]>NoHeaders to be sent with the request.

Returns: customeraccount:CustomerElectronicAddress|error

Sample code:

customeraccount:CustomerElectronicAddress address = check fo->createCustomerElectronicAddresses({
dataAreaId: "USMF",
customerAccount: "CUST-3001",
electronicAddressId: "EA-0001",
'type: "Email",
locator: "[email protected]",
purpose: "Business",
description: "Primary accounts payable contact",
isPrimary: "Yes",
isPrivate: "No"
});
getCustomerElectronicAddresses

Reads a specific customer electronic address by key.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
electronicAddressIdstringYesThe electronic address id key field.
customerAccountstringYesThe customer account key field.
headersmap<string|string[]>NoHeaders to be sent with the request.
queriesGetCustomerElectronicAddressesQueriesNoOData query parameters: $expand, $select.

Returns: customeraccount:CustomerElectronicAddress|error

Sample code:

customeraccount:CustomerElectronicAddress address = check fo->getCustomerElectronicAddresses(
"USMF",
"EA-0001",
"CUST-3001"
);
deleteCustomerElectronicAddresses

Deletes a specific customer electronic address.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
electronicAddressIdstringYesThe electronic address id key field.
customerAccountstringYesThe customer account key field.
headersDeleteCustomerElectronicAddressesHeadersNoOptional ifMatch ETag header for optimistic concurrency; mapped to If-Match.

Returns: error?

Sample code:

check fo->deleteCustomerElectronicAddresses(
"USMF",
"EA-0001",
"CUST-3001",
headers = {ifMatch: eTag}
);
updateCustomerElectronicAddresses

Updates a specific customer electronic address.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
electronicAddressIdstringYesThe electronic address id key field.
customerAccountstringYesThe customer account key field.
payloadCustomerElectronicAddressYesThe fields to update.
headersUpdateCustomerElectronicAddressesHeadersNoOptional ifMatch ETag header for optimistic concurrency; mapped to If-Match.

Returns: customeraccount:CustomerElectronicAddress|error

Sample code:

customeraccount:CustomerElectronicAddress updated = check fo->updateCustomerElectronicAddresses(
"USMF",
"EA-0001",
"CUST-3001",
{isPrimary: "No"},
headers = {ifMatch: eTag}
);

Customer payment journal headers

listCustomerPaymentJournalHeaders

Reads all customer payment journal headers.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoHeaders to be sent with the request.
queriesListCustomerPaymentJournalHeadersQueriesNoOData query parameters: $skip, $top, $filter, $orderby, $expand, cross-company, $count, $select.

Returns: customeraccount:CustomerPaymentJournalHeadersCollection|error

Sample code:

customeraccount:CustomerPaymentJournalHeadersCollection headers = check fo->listCustomerPaymentJournalHeaders(
queries = {
filter: "JournalName eq 'CustPayment' and IsPosted eq 'No'",
top: 20
}
);
createCustomerPaymentJournalHeaders

Creates a customer payment journal header.

Parameters:

NameTypeRequiredDescription
payloadCustomerPaymentJournalHeaderYesThe customer payment journal header to create.
headersmap<string|string[]>NoHeaders to be sent with the request.

Returns: customeraccount:CustomerPaymentJournalHeader|error

Sample code:

customeraccount:CustomerPaymentJournalHeader header = check fo->createCustomerPaymentJournalHeaders({
dataAreaId: "USMF",
journalBatchNumber: "CustPmt-000123",
journalName: "CustPayment",
description: "Customer payments - August batch",
isPosted: "No",
overrideSalesTax: "No"
});
getCustomerPaymentJournalHeaders

Reads a specific customer payment journal header by key.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
journalBatchNumberstringYesThe journal batch number key field.
headersmap<string|string[]>NoHeaders to be sent with the request.
queriesGetCustomerPaymentJournalHeadersQueriesNoOData query parameters: $expand, $select.

Returns: customeraccount:CustomerPaymentJournalHeader|error

Sample code:

customeraccount:CustomerPaymentJournalHeader header = check fo->getCustomerPaymentJournalHeaders(
"USMF",
"CustPmt-000123"
);
deleteCustomerPaymentJournalHeaders

Deletes a specific customer payment journal header.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
journalBatchNumberstringYesThe journal batch number key field.
headersDeleteCustomerPaymentJournalHeadersHeadersNoOptional ifMatch ETag header for optimistic concurrency; mapped to If-Match.

Returns: error?

Sample code:

check fo->deleteCustomerPaymentJournalHeaders(
"USMF",
"CustPmt-000123",
headers = {ifMatch: eTag}
);
updateCustomerPaymentJournalHeaders

Updates a specific customer payment journal header.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
journalBatchNumberstringYesThe journal batch number key field.
payloadCustomerPaymentJournalHeaderYesThe fields to update.
headersUpdateCustomerPaymentJournalHeadersHeadersNoOptional ifMatch ETag header for optimistic concurrency; mapped to If-Match.

Returns: customeraccount:CustomerPaymentJournalHeader|error

Sample code:

customeraccount:CustomerPaymentJournalHeader updated = check fo->updateCustomerPaymentJournalHeaders(
"USMF",
"CustPmt-000123",
{description: "Customer payments - August batch (revised)"},
headers = {ifMatch: eTag}
);

Customer payment journal lines

listCustomerPaymentJournalLines

Reads all customer payment journal lines.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoHeaders to be sent with the request.
queriesListCustomerPaymentJournalLinesQueriesNoOData query parameters: $skip, $top, $filter, $orderby, $expand, cross-company, $count, $select.

Returns: customeraccount:CustomerPaymentJournalLinesCollection|error

Sample code:

customeraccount:CustomerPaymentJournalLinesCollection lines = check fo->listCustomerPaymentJournalLines(
queries = {
filter: "JournalBatchNumber eq 'CustPmt-000123'",
orderby: "LineNumber asc"
}
);
createCustomerPaymentJournalLines

Creates a customer payment journal line.

Parameters:

NameTypeRequiredDescription
payloadCustomerPaymentJournalLineYesThe customer payment journal line to create.
headersmap<string|string[]>NoHeaders to be sent with the request.

Returns: customeraccount:CustomerPaymentJournalLine|error

Sample code:

customeraccount:CustomerPaymentJournalLine line = check fo->createCustomerPaymentJournalLines({
dataAreaId: "USMF",
journalBatchNumber: "CustPmt-000123",
lineNumber: 1,
accountType: "Cust",
accountDisplayValue: "CUST-3001",
offsetAccountType: "Bank",
offsetAccountDisplayValue: "USMF OPER USD",
creditAmount: 1500.00,
currencyCode: "USD",
transactionText: "Payment received - INV-000456",
paymentMethodName: "CHECK",
customerName: "Contoso Retail"
});
getCustomerPaymentJournalLines

Reads a specific customer payment journal line by key.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
journalBatchNumberstringYesThe journal batch number key field.
lineNumberdecimalYesThe line number key field.
headersmap<string|string[]>NoHeaders to be sent with the request.
queriesGetCustomerPaymentJournalLinesQueriesNoOData query parameters: $expand, $select.

Returns: customeraccount:CustomerPaymentJournalLine|error

Sample code:

customeraccount:CustomerPaymentJournalLine line = check fo->getCustomerPaymentJournalLines(
"USMF",
"CustPmt-000123",
1
);
deleteCustomerPaymentJournalLines

Deletes a specific customer payment journal line.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
journalBatchNumberstringYesThe journal batch number key field.
lineNumberdecimalYesThe line number key field.
headersDeleteCustomerPaymentJournalLinesHeadersNoOptional ifMatch ETag header for optimistic concurrency; mapped to If-Match.

Returns: error?

Sample code:

check fo->deleteCustomerPaymentJournalLines(
"USMF",
"CustPmt-000123",
1,
headers = {ifMatch: eTag}
);
updateCustomerPaymentJournalLines

Updates a specific customer payment journal line.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
journalBatchNumberstringYesThe journal batch number key field.
lineNumberdecimalYesThe line number key field.
payloadCustomerPaymentJournalLineYesThe fields to update.
headersUpdateCustomerPaymentJournalLinesHeadersNoOptional ifMatch ETag header for optimistic concurrency; mapped to If-Match.

Returns: customeraccount:CustomerPaymentJournalLine|error

Sample code:

customeraccount:CustomerPaymentJournalLine updated = check fo->updateCustomerPaymentJournalLines(
"USMF",
"CustPmt-000123",
1,
{creditAmount: 1600.00},
headers = {ifMatch: eTag}
);

Customer payment methods

listCustomerPaymentMethods

Reads all customer payment methods.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoHeaders to be sent with the request.
queriesListCustomerPaymentMethodsQueriesNoOData query parameters: $skip, $top, $filter, $orderby, $expand, cross-company, $count, $select.

Returns: customeraccount:CustomerPaymentMethodsCollection|error

Sample code:

customeraccount:CustomerPaymentMethodsCollection methods = check fo->listCustomerPaymentMethods(
queries = {
filter: "PaymentType eq 'Check'",
'select: "Name,Description,PaymentType,IsSEPA,DirectDebit"
}
);
createCustomerPaymentMethods

Creates a customer payment method.

Parameters:

NameTypeRequiredDescription
payloadCustomerPaymentMethodYesThe customer payment method to create.
headersmap<string|string[]>NoHeaders to be sent with the request.

Returns: customeraccount:CustomerPaymentMethod|error

Sample code:

customeraccount:CustomerPaymentMethod method = check fo->createCustomerPaymentMethods({
dataAreaId: "USMF",
name: "CHECK",
description: "Check payment",
paymentType: "Check",
accountType: "Cust",
isSEPA: "No",
directDebit: "No",
paymentJournalName: "CustPayment"
});
getCustomerPaymentMethods

Reads a specific customer payment method by key.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
namestringYesThe name key field.
headersmap<string|string[]>NoHeaders to be sent with the request.
queriesGetCustomerPaymentMethodsQueriesNoOData query parameters: $expand, $select.

Returns: customeraccount:CustomerPaymentMethod|error

Sample code:

customeraccount:CustomerPaymentMethod method = check fo->getCustomerPaymentMethods(
"USMF",
"CHECK"
);
deleteCustomerPaymentMethods

Deletes a specific customer payment method.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
namestringYesThe name key field.
headersDeleteCustomerPaymentMethodsHeadersNoOptional ifMatch ETag header for optimistic concurrency; mapped to If-Match.

Returns: error?

Sample code:

check fo->deleteCustomerPaymentMethods(
"USMF",
"CHECK",
headers = {ifMatch: eTag}
);
updateCustomerPaymentMethods

Updates a specific customer payment method.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
namestringYesThe name key field.
payloadCustomerPaymentMethodYesThe fields to update.
headersUpdateCustomerPaymentMethodsHeadersNoOptional ifMatch ETag header for optimistic concurrency; mapped to If-Match.

Returns: customeraccount:CustomerPaymentMethod|error

Sample code:

customeraccount:CustomerPaymentMethod updated = check fo->updateCustomerPaymentMethods(
"USMF",
"CHECK",
{directDebit: "Yes"},
headers = {ifMatch: eTag}
);

Customer postal addresses

listCustomerPostalAddressesV2

Reads all customer postal addresses.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoHeaders to be sent with the request.
queriesListCustomerPostalAddressesV2QueriesNoOData query parameters: $skip, $top, $filter, $orderby, $expand, cross-company, $count, $select.

Returns: customeraccount:CustomerPostalAddressesV2Collection|error

Sample code:

customeraccount:CustomerPostalAddressesV2Collection addresses = check fo->listCustomerPostalAddressesV2(
queries = {
filter: "CustomerAccount eq 'CUST-3001' and IsPrimary eq 'Yes'",
top: 10
}
);
createCustomerPostalAddressesV2

Creates a customer postal address.

Parameters:

NameTypeRequiredDescription
payloadCustomerPostalAddressV2YesThe customer postal address to create.
headersmap<string|string[]>NoHeaders to be sent with the request.

Returns: customeraccount:CustomerPostalAddressV2|error

Sample code:

customeraccount:CustomerPostalAddressV2 address = check fo->createCustomerPostalAddressesV2({
dataAreaId: "USMF",
customerAccount: "CUST-3001",
addressLocationId: "LOC-001",
addressDescription: "Head office",
addressStreet: "123 Market Street",
addressStreetNumber: "123",
addressCity: "Seattle",
addressState: "WA",
addressZipCode: "98101",
addressCountryRegionId: "USA",
addressCountryRegionISOCode: "US",
isPrimary: "Yes",
isPrivate: "No"
});
getCustomerPostalAddressesV2

Reads a specific customer postal address by key.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
customerAccountstringYesThe customer account key field.
addressLocationIdstringYesThe address location id key field.
headersmap<string|string[]>NoHeaders to be sent with the request.
queriesGetCustomerPostalAddressesV2QueriesNoOData query parameters: $expand, $select.

Returns: customeraccount:CustomerPostalAddressV2|error

Sample code:

customeraccount:CustomerPostalAddressV2 address = check fo->getCustomerPostalAddressesV2(
"USMF",
"CUST-3001",
"LOC-001"
);
deleteCustomerPostalAddressesV2

Deletes a specific customer postal address.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
customerAccountstringYesThe customer account key field.
addressLocationIdstringYesThe address location id key field.
headersDeleteCustomerPostalAddressesV2HeadersNoOptional ifMatch ETag header for optimistic concurrency; mapped to If-Match.

Returns: error?

Sample code:

check fo->deleteCustomerPostalAddressesV2(
"USMF",
"CUST-3001",
"LOC-001",
headers = {ifMatch: eTag}
);
updateCustomerPostalAddressesV2

Updates a specific customer postal address.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
customerAccountstringYesThe customer account key field.
addressLocationIdstringYesThe address location id key field.
payloadCustomerPostalAddressV2YesThe fields to update.
headersUpdateCustomerPostalAddressesV2HeadersNoOptional ifMatch ETag header for optimistic concurrency; mapped to If-Match.

Returns: customeraccount:CustomerPostalAddressV2|error

Sample code:

customeraccount:CustomerPostalAddressV2 updated = check fo->updateCustomerPostalAddressesV2(
"USMF",
"CUST-3001",
"LOC-001",
{addressZipCode: "98104"},
headers = {ifMatch: eTag}
);

Customer posting profiles

listCustomerPostingProfiles

Reads all customer posting profiles.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoHeaders to be sent with the request.
queriesListCustomerPostingProfilesQueriesNoOData query parameters: $skip, $top, $filter, $orderby, $expand, cross-company, $count, $select.

Returns: customeraccount:CustomerPostingProfilesCollection|error

Sample code:

customeraccount:CustomerPostingProfilesCollection profiles = check fo->listCustomerPostingProfiles(
queries = {
filter: "dataAreaId eq 'USMF'"
}
);
createCustomerPostingProfiles

Creates a customer posting profile.

Parameters:

NameTypeRequiredDescription
payloadCustomerPostingProfileYesThe customer posting profile to create.
headersmap<string|string[]>NoHeaders to be sent with the request.

Returns: customeraccount:CustomerPostingProfile|error

Sample code:

customeraccount:CustomerPostingProfile profile = check fo->createCustomerPostingProfiles({
dataAreaId: "USMF",
postingProfile: "CustDefault",
description: "Default customer posting profile",
isTransactionIncludedInAutoSettlement: "Yes",
isTransactionIncludedInInterestCalculation: "Yes",
isTransactionIncludedInCollectionLetterGeneration: "Yes"
});
getCustomerPostingProfiles

Reads a specific customer posting profile by key.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
postingProfilestringYesThe posting profile key field.
headersmap<string|string[]>NoHeaders to be sent with the request.
queriesGetCustomerPostingProfilesQueriesNoOData query parameters: $expand, $select.

Returns: customeraccount:CustomerPostingProfile|error

Sample code:

customeraccount:CustomerPostingProfile profile = check fo->getCustomerPostingProfiles(
"USMF",
"CustDefault"
);
deleteCustomerPostingProfiles

Deletes a specific customer posting profile.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
postingProfilestringYesThe posting profile key field.
headersDeleteCustomerPostingProfilesHeadersNoOptional ifMatch ETag header for optimistic concurrency; mapped to If-Match.

Returns: error?

Sample code:

check fo->deleteCustomerPostingProfiles(
"USMF",
"CustDefault",
headers = {ifMatch: eTag}
);
updateCustomerPostingProfiles

Updates a specific customer posting profile.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
postingProfilestringYesThe posting profile key field.
payloadCustomerPostingProfileYesThe fields to update.
headersUpdateCustomerPostingProfilesHeadersNoOptional ifMatch ETag header for optimistic concurrency; mapped to If-Match.

Returns: customeraccount:CustomerPostingProfile|error

Sample code:

customeraccount:CustomerPostingProfile updated = check fo->updateCustomerPostingProfiles(
"USMF",
"CustDefault",
{isTransactionIncludedInCollectionLetterGeneration: "No"},
headers = {ifMatch: eTag}
);