Skip to main content

Actions

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

ClientPurpose
ClientProvides full CRUD access to Microsoft Dynamics 365 Finance customer master data via the Customer Main OData API.

Client​

Provides full CRUD access to Microsoft Dynamics 365 Finance customer master data via the Customer Main OData API.

Configuration​

FieldTypeDefaultDescription
authOAuth2ClientCredentialsGrantConfigRequiredOAuth 2.0 client credentials grant configuration; includes tokenUrl, clientId, clientSecret, and scopes.
httpVersionstring"2.0"HTTP protocol version to use for outbound requests.
http1SettingsClientHttp1Settings{}HTTP/1.x client settings including keep-alive, chunking, and proxy configuration.
secureSockethttp:ClientSecureSocket()SSL/TLS configuration for secure connections.
proxyProxyConfig()Proxy server configuration.

Initializing the client​

import ballerinax/microsoft.dynamics365.finance.customermain;

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

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

Operations​

Customers V2​

listCustomersV2

Reads all CustomersV2 records in the system.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesListCustomersV2QueriesNoOData query parameters, set via the record fields skip ($skip), top ($top), filter ($filter), orderby ($orderby), expand ($expand), crossCompany (cross-company), count ($count), and 'select ($select).

Returns: CustomersV2Collection|error

Sample code:

customermain:CustomersV2Collection result = check fo->listCustomersV2(
queries = {
filter: "CustomerGroupId eq '10'",
top: 20,
'select: "CustomerAccount,OrganizationName,CreditLimit,SalesCurrencyCode"
}
);
createCustomersV2

Creates a CustomersV2 record.

Parameters:

NameTypeRequiredDescription
payloadCustomerV2YesThe customer master record to create.
headersmap<string|string[]>NoAdditional HTTP request headers.

Returns: CustomerV2|error

Sample code:

customermain:CustomerV2 created = check fo->createCustomersV2({
dataAreaId: "USMF",
customerAccount: "US-101",
organizationName: "Contoso Retail Inc.",
customerGroupId: "10",
invoiceAccount: "US-101",
salesCurrencyCode: "USD",
paymentTerms: "Net30",
creditLimit: 50000,
addressStreet: "500 Boylston Street",
addressCity: "Boston",
addressZipCode: "02116",
addressCountryRegionId: "USA",
primaryContactEmail: "[email protected]",
languageId: "en-us"
});
getCustomersV2

Reads a specific CustomersV2 record by its composite key.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier (e.g., "USMF").
customerAccountstringYesThe customer account key field (e.g., "US-101").
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesGetCustomersV2QueriesNoOData query parameters, set via the record fields expand ($expand) and 'select ($select).

Returns: CustomerV2|error

Sample code:

customermain:CustomerV2 customer = check fo->getCustomersV2(
"USMF",
"US-101",
queries = {
'select: "CustomerAccount,OrganizationName,CreditLimit,OnHoldStatus"
}
);
deleteCustomersV2

Deletes a specific CustomersV2 record.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
customerAccountstringYesThe customer account key field of the record to delete.
headersDeleteCustomersV2HeadersNoRequest headers; supports an optional ifMatch field mapped to the If-Match header, used for optimistic concurrency.

Returns: error?

Sample code:

check fo->deleteCustomersV2(
"USMF",
"US-101",
headers = {ifMatch: eTag}
);
updateCustomersV2

Updates a specific CustomersV2 record.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
customerAccountstringYesThe customer account key field of the record to update.
payloadCustomerV2YesThe fields to update.
headersUpdateCustomersV2HeadersNoRequest headers; supports an optional ifMatch field mapped to the If-Match header, used for optimistic concurrency.

Returns: CustomerV2|error

Sample code:

customermain:CustomerV2 updated = check fo->updateCustomersV2(
"USMF",
"US-101",
{
creditLimit: 75000,
onHoldStatus: "Invoice"
},
headers = {ifMatch: eTag}
);

Customers V3​

listCustomersV3

Reads all CustomersV3 records in the system.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesListCustomersV3QueriesNoOData query parameters, set via the record fields skip ($skip), top ($top), filter ($filter), orderby ($orderby), expand ($expand), crossCompany (cross-company), count ($count), and 'select ($select).

Returns: CustomersV3Collection|error

Sample code:

customermain:CustomersV3Collection result = check fo->listCustomersV3(
queries = {
filter: "CredManGroupId eq 'STD'",
orderby: "OrganizationName asc",
'select: "CustomerAccount,OrganizationName,CreditLimit,CredManGroupId"
}
);
createCustomersV3

Creates a CustomersV3 record.

Parameters:

NameTypeRequiredDescription
payloadCustomerV3YesThe customer master record to create.
headersmap<string|string[]>NoAdditional HTTP request headers.

Returns: CustomerV3|error

Sample code:

customermain:CustomerV3 created = check fo->createCustomersV3({
dataAreaId: "USMF",
customerAccount: "US-102",
organizationName: "Fabrikam Industrial Supply",
customerGroupId: "20",
invoiceAccount: "US-102",
salesCurrencyCode: "USD",
paymentTerms: "Net45",
creditLimit: 120000,
credManGroupId: "STD",
credManCustUnlimitedCredit: "No",
fulfillmentPolicyName: "StandardFulfillment",
collectionLetterCode: "CollectionLetter1",
addressStreet: "88 Industrial Parkway",
addressCity: "Cleveland",
addressZipCode: "44101",
addressCountryRegionId: "USA",
languageId: "en-us"
});
getCustomersV3

Reads a specific CustomersV3 record by its composite key.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier (e.g., "USMF").
customerAccountstringYesThe customer account key field (e.g., "US-102").
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesGetCustomersV3QueriesNoOData query parameters, set via the record fields expand ($expand) and 'select ($select).

Returns: CustomerV3|error

Sample code:

customermain:CustomerV3 customer = check fo->getCustomersV3(
"USMF",
"US-102",
queries = {
'select: "CustomerAccount,OrganizationName,CreditLimit,CredManGroupId,OnHoldStatus"
}
);
deleteCustomersV3

Deletes a specific CustomersV3 record.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
customerAccountstringYesThe customer account key field of the record to delete.
headersDeleteCustomersV3HeadersNoRequest headers; supports an optional ifMatch field mapped to the If-Match header, used for optimistic concurrency.

Returns: error?

Sample code:

check fo->deleteCustomersV3(
"USMF",
"US-102",
headers = {ifMatch: eTag}
);
updateCustomersV3

Updates a specific CustomersV3 record.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
customerAccountstringYesThe customer account key field of the record to update.
payloadCustomerV3YesThe fields to update.
headersUpdateCustomersV3HeadersNoRequest headers; supports an optional ifMatch field mapped to the If-Match header, used for optimistic concurrency.

Returns: CustomerV3|error

Sample code:

customermain:CustomerV3 updated = check fo->updateCustomersV3(
"USMF",
"US-102",
{
creditLimit: 150000,
credManCustUnlimitedCredit: "Yes"
},
headers = {ifMatch: eTag}
);