Business central API: How to get the general ledger entries of a posted sale invoice ?

Hello,

How can we get the general ledger entries of a posted sale invoice via the API of business central ?

We tried with the following request

..../api.businesscentral.dynamics.com/v1.0/api/beta/companies(id)/generalLedgerEntries?$top=100&$filter=(documentNumber eq '1910022') and (documentType eq 'Invoice')

but FILTER on documentNumber is not 100% correct because i assume documentNumber 1910022 could concern also a posted purchase invoice or even other thing.

Thank in advance for your help.

Regards.

Guy

Parents
  • Hi,

    You can, for example, refer to the Navigate function to see how this kind of filtering is handled in standard NAV / BC. If you open a posted invoice click Navigate and drill down to G/L entries, you can see that there are two filter applied on the record: Document No. and Posting Date. In fact, these are the only two parameters that are passed to the Navigate page. Usual practice assumes that numbers to posted documents should be assigned in a way that rules out intersections. Different document types should always have different numbers.

    But, if you have doubts in the correctness of filtering, you can set additional filter on the "Source Code" field - for sales it will be 'SALES'.

Reply Children
Related
Recommended