我无法读取Dynamics BC中特定的表格,使用Power BI。

huangapple go评论57阅读模式
英文:

I can't read specific tables of Dynamics BC with Power BI

问题

我在将我们的ERP(Dynamics Business Central)的某些表格与Power BI同步时遇到了问题。我正在执行的步骤如下:

  1. 获取数据
  2. 搜索Dynamics 365 Business Central
  3. 搜索相关表格

这是当我尝试预览名为'salesCreditMemoLines'的表格中的信息时,Power BI不让我进行预览(与我可以无问题地查看其他表格不同)。

我感激您在这个问题上的帮助。

英文:

I am having troubles sincronising certain tables of our ERP (Dynamics Business Central) with Power BI. The steps that I am doing are explained below:

  1. Get Data
  2. Search Dynamics 365 Business central
  3. Search for the relevant tables

This is when Power BI doesn´t let me preview the information within the table called 'salesCreditMemoLines' (我无法读取Dynamics BC中特定的表格,使用Power BI。), contrary to other tables that I can see without troubles (我无法读取Dynamics BC中特定的表格,使用Power BI。)

I appreciate your help in this issue.

答案1

得分: 1

这是预期的错误。在Business Central API中,文档行集合需要在请求中包含相应的文档 ID,否则请求将失败。

以下是API页面中引发此错误的代码部分。

IdFilter := GetFilter(SystemId);
DocumentIdFilter := GetFilter("Document Id");
if (IdFilter = '') and (DocumentIdFilter = '') then
    Error(IDOrDocumentIdShouldBeSpecifiedForLinesErr);

有两种方法可以发送文档 ID。我下面的示例是针对销售订单的查询,但对所有文档集合都适用。
第一种方法是使用 $expand 语法,请求文档头和文档行:

https://api.businesscentral.dynamics.com/v2.0/{{tenantid}}/{{environmentname}}/api/v2.0/companies({companyId})/salesOrders(orderId)$expand=salesOrderLines

另一种选择是通过添加 $filter 参数来查询文档行:

https://api.businesscentral.dynamics.com/v2.0/{{tenantid}}/{{environmentname}}/api/v2.0/companies(companyId)/salesOrderLines?$filter=documentId eq salesOrderId

筛选条件可以包括范围,因此可以请求多个文档的行集合。
https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/webservices/use-filter-expressions-in-odata-uris

然而,这两种方法都不适用于 Power BI 数据源选择。一个替代方法是在“Web Services(传统)”选项下使用实体销售文档行。是的,它显示为传统,但迄今为止,Microsoft 还没有宣布移除 OData Web 服务的计划。

https://learn.microsoft.com/en-us/dynamics365-release-plan/2021wave1/smb/dynamics365-business-central/enable-power-bi-connector-work-business-central-apis-instead-web-services-only

英文:

This is expected error. Document lines collections in Business Central API require the respective document ID to be present in the request, otherwise it fails.

This is the piece of code from the API page that throws this error.

    IdFilter := GetFilter(SystemId);
    DocumentIdFilter := GetFilter("Document Id");
    if (IdFilter = '') and (DocumentIdFilter = '') then
        Error(IDOrDocumentIdShouldBeSpecifiedForLinesErr);

There are two ways to send the document ID. My examples below are querying sales orders, but the same applies to all document collections.
First is request the lines along with the document header using $expand syntax:

https://api.businesscentral.dynamics.com/v2.0/{{tenantid}}/{{environmentname}}/api/v2.0/companies({companyId})/salesOrders(orderId)$expand=salesOrderLines

Another option is to query the document lines adding the $filter parameter:

https://api.businesscentral.dynamics.com/v2.0/{{tenantid}}/{{environmentname}}/api/v2.0/companies(companyId)/salesOrderLines?$filter=documentId eq salesOrderId

Filters can include ranges, so this way it's possible to request a collection of lines from multiple documents.
https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/webservices/use-filter-expressions-in-odata-uris

Neither of these methods is going to work in Power BI data source selection, though. An alternative way is to use an entity salesDocumentLines under the Web Services (legacy) option. Yes, it shows as legacy, but so far Microsoft has not announced any plans to remove the OData web services.

https://learn.microsoft.com/en-us/dynamics365-release-plan/2021wave1/smb/dynamics365-business-central/enable-power-bi-connector-work-business-central-apis-instead-web-services-only

huangapple
  • 本文由 发表于 2023年2月17日 23:32:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/75486272.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定