Skip to main content

Actions

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

ClientPurpose
ClientProvides full CRUD access to Microsoft Dynamics 365 Finance Vendor entities via the OData REST API.

Client​

Provides full CRUD access to Microsoft Dynamics 365 Finance Vendor entities via the OData REST API.

Configuration​

FieldTypeDefaultDescription
authOAuth2ClientCredentialsGrantConfigRequiredOAuth2 client credentials grant configuration used to obtain an access token from Microsoft Entra ID.
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.vendor;

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

configurable string[] scopes = ["https://<your-org>.operations.dynamics.com/.default"];

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

Operations​

Vendor groups​

listVendorGroups

Reads all vendor groups in the system.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesListVendorGroupsQueriesNoOData query parameters: $skip, $top, $filter, $orderby, $expand, cross-company, $count, $select.

Returns: vendor:VendorGroupsCollection|error

Sample code:

vendor:VendorGroupsCollection result = check fo->listVendorGroups(
queries = {
filter: "DefaultTaxGroupCode eq 'TAX-STD'",
top: 20,
'select: "VendorGroupId,Description,DefaultPaymentTermName"
}
);
createVendorGroups

Creates a vendor group.

Parameters:

NameTypeRequiredDescription
payloadVendorGroupYesThe vendor group to create.
headersmap<string|string[]>NoAdditional HTTP request headers.

Returns: vendor:VendorGroup|error

Sample code:

vendor:VendorGroup created = check fo->createVendorGroups({
dataAreaId: "USMF",
vendorGroupId: "DOMESTIC",
description: "Domestic vendors",
defaultTaxGroupCode: "TAX-STD",
defaultPaymentTermName: "NET30"
});
getVendorGroups

Reads a specific vendor group.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier (e.g., "USMF").
vendorGroupIdstringYesThe vendor group id key field.
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesGetVendorGroupsQueriesNoOData query parameters: $expand, $select.

Returns: vendor:VendorGroup|error

Sample code:

vendor:VendorGroup vendorGroup = check fo->getVendorGroups("USMF", "DOMESTIC");
deleteVendorGroups

Deletes a specific vendor group.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
vendorGroupIdstringYesThe vendor group id key field.
headersDeleteVendorGroupsHeadersNoAdditional HTTP request headers; set ifMatch to the entity's current ETag for optimistic concurrency.

Returns: error?

Sample code:

check fo->deleteVendorGroups("USMF", "DOMESTIC", headers = {ifMatch: eTag});
updateVendorGroups

Updates a specific vendor group.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
vendorGroupIdstringYesThe vendor group id key field.
payloadVendorGroupYesFields to update.
headersUpdateVendorGroupsHeadersNoAdditional HTTP request headers; set ifMatch to the entity's current ETag for optimistic concurrency.

Returns: vendor:VendorGroup|error

Sample code:

vendor:VendorGroup updated = check fo->updateVendorGroups(
"USMF",
"DOMESTIC",
{defaultPaymentTermName: "NET45"},
headers = {ifMatch: eTag}
);

Vendor parameters​

listVendorParameters

Reads the vendor (accounts payable) parameters for every company in the system.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesListVendorParametersQueriesNoOData query parameters: $skip, $top, $filter, $orderby, $expand, cross-company, $count, $select.

Returns: vendor:VendorParametersCollection|error

Sample code:

vendor:VendorParametersCollection result = check fo->listVendorParameters(
queries = {
crossCompany: true
}
);
createVendorParameters

Creates the vendor parameters record for a company.

Parameters:

NameTypeRequiredDescription
payloadVendorParameterYesThe vendor parameter fields to create.
headersmap<string|string[]>NoAdditional HTTP request headers.

Returns: vendor:VendorParameter|error

Sample code:

vendor:VendorParameter created = check fo->createVendorParameters({
dataAreaId: "USMF",
taxGroup: "TAX-STD",
postingProfile: "VEND",
mandatoryTaxGroup: "Yes"
});
getVendorParameters

Reads the vendor parameters for a specific company.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesGetVendorParametersQueriesNoOData query parameters: $expand, $select.

Returns: vendor:VendorParameter|error

Sample code:

vendor:VendorParameter parameters = check fo->getVendorParameters("USMF");
deleteVendorParameters

Deletes the vendor parameters record for a specific company.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
headersDeleteVendorParametersHeadersNoAdditional HTTP request headers; set ifMatch to the entity's current ETag for optimistic concurrency.

Returns: error?

Sample code:

check fo->deleteVendorParameters("USMF", headers = {ifMatch: eTag});
updateVendorParameters

Updates the vendor parameters record for a specific company.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
payloadVendorParameterYesFields to update.
headersUpdateVendorParametersHeadersNoAdditional HTTP request headers; set ifMatch to the entity's current ETag for optimistic concurrency.

Returns: vendor:VendorParameter|error

Sample code:

vendor:VendorParameter updated = check fo->updateVendorParameters(
"USMF",
{mandatoryTaxGroup: "No"},
headers = {ifMatch: eTag}
);

Vendor reasons​

listVendorReasons

Reads all vendor reason codes in the system.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesListVendorReasonsQueriesNoOData query parameters: $skip, $top, $filter, $orderby, $expand, cross-company, $count, $select.

Returns: vendor:VendorReasonsCollection|error

Sample code:

vendor:VendorReasonsCollection result = check fo->listVendorReasons(
queries = {
filter: "ForVendorTransactionType eq Microsoft.Dynamics.DataEntities.NoYes'Yes'"
}
);
createVendorReasons

Creates a vendor reason code.

Parameters:

NameTypeRequiredDescription
payloadVendorReasonsYesThe vendor reason code to create.
headersmap<string|string[]>NoAdditional HTTP request headers.

Returns: vendor:VendorReasons|error

Sample code:

vendor:VendorReasons created = check fo->createVendorReasons({
dataAreaId: "USMF",
reasonCode: "DUPLICATE",
defaultComment: "Duplicate invoice received",
cancellationReason: "Yes",
forVendorTransactionType: "Yes"
});
getVendorReasons

Reads a specific vendor reason code.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
reasonCodestringYesThe reason code key field.
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesGetVendorReasonsQueriesNoOData query parameters: $expand, $select.

Returns: vendor:VendorReasons|error

Sample code:

vendor:VendorReasons reason = check fo->getVendorReasons("USMF", "DUPLICATE");
deleteVendorReasons

Deletes a specific vendor reason code.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
reasonCodestringYesThe reason code key field.
headersDeleteVendorReasonsHeadersNoAdditional HTTP request headers; set ifMatch to the entity's current ETag for optimistic concurrency.

Returns: error?

Sample code:

check fo->deleteVendorReasons("USMF", "DUPLICATE", headers = {ifMatch: eTag});
updateVendorReasons

Updates a specific vendor reason code.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
reasonCodestringYesThe reason code key field.
payloadVendorReasonsYesFields to update.
headersUpdateVendorReasonsHeadersNoAdditional HTTP request headers; set ifMatch to the entity's current ETag for optimistic concurrency.

Returns: vendor:VendorReasons|error

Sample code:

vendor:VendorReasons updated = check fo->updateVendorReasons(
"USMF",
"DUPLICATE",
{defaultComment: "Duplicate vendor invoice - written off"},
headers = {ifMatch: eTag}
);

Vendors​

listVendors

Reads all vendors in the system.

Parameters:

NameTypeRequiredDescription
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesListVendorsQueriesNoOData query parameters: $skip, $top, $filter, $orderby, $expand, cross-company, $count, $select.

Returns: vendor:VendorsCollection|error

Sample code:

vendor:VendorsCollection result = check fo->listVendors(
queries = {
filter: "VendorGroupId eq 'DOMESTIC'",
top: 25,
'select: "VendorAccountNumber,VendorName,CurrencyCode,OnHoldStatus"
}
);
createVendors

Creates a vendor.

Parameters:

NameTypeRequiredDescription
payloadVendorYesThe vendor to create.
headersmap<string|string[]>NoAdditional HTTP request headers.

Returns: vendor:Vendor|error

Sample code:

vendor:Vendor created = check fo->createVendors({
dataAreaId: "USMF",
vendorAccountNumber: "US-100234",
vendorName: "Contoso Office Supplies",
vendorGroupId: "DOMESTIC",
currencyCode: "USD",
languageId: "en-us",
defaultPaymentTermsName: "NET30",
onHoldStatus: "No"
});
getVendors

Reads a specific vendor.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
vendorAccountNumberstringYesThe vendor account number key field.
headersmap<string|string[]>NoAdditional HTTP request headers.
queriesGetVendorsQueriesNoOData query parameters: $expand, $select.

Returns: vendor:Vendor|error

Sample code:

vendor:Vendor vendorRecord = check fo->getVendors(
"USMF",
"US-100234",
queries = {
'select: "VendorAccountNumber,VendorName,OnHoldStatus,CreditLimit"
}
);
deleteVendors

Deletes a specific vendor.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
vendorAccountNumberstringYesThe vendor account number key field.
headersDeleteVendorsHeadersNoAdditional HTTP request headers; set ifMatch to the entity's current ETag for optimistic concurrency.

Returns: error?

Sample code:

check fo->deleteVendors("USMF", "US-100234", headers = {ifMatch: eTag});
updateVendors

Updates a specific vendor.

Parameters:

NameTypeRequiredDescription
dataAreaIdstringYesThe company data area identifier.
vendorAccountNumberstringYesThe vendor account number key field.
payloadVendorYesFields to update.
headersUpdateVendorsHeadersNoAdditional HTTP request headers; set ifMatch to the entity's current ETag for optimistic concurrency.

Returns: vendor:Vendor|error

Sample code:

vendor:Vendor updated = check fo->updateVendors(
"USMF",
"US-100234",
{onHoldStatus: "Invoice", creditLimit: 50000.00},
headers = {ifMatch: eTag}
);