如何通过Business Central API 2.0获取Customer Price Group
在Business Central中获取客户价格组的方法
1. 通过API获取
- 获取单个客户的关联价格组:调用
customers实体接口,指定客户ID后,返回结果中的priceGroupCode字段即为该客户的价格组编码。示例请求:GET /companies({companyId})/customers({customerId})?$select=priceGroupCode - 获取系统中所有客户价格组:直接调用
customerPriceGroups实体接口,可返回所有已配置的价格组完整信息(编码、名称等):GET /companies({companyId})/customerPriceGroups
2. 客户端操作查看
- 查看单个客户的价格组:打开客户列表,选中目标客户进入客户卡片,在销售&收款标签页下找到「价格组」字段。
- 查看所有价格组定义:在系统搜索栏输入「客户价格组」,打开对应页面即可查看所有已创建的价格组。
3. AL开发方式获取
如果需要在自定义功能中读取价格组数据,可使用以下AL代码:
- 获取单个客户的价格组:
var Customer: Record Customer; PriceGroupCode: Code[20]; begin if Customer.Get('CUST001') then begin // 替换为实际客户ID PriceGroupCode := Customer."Price Group Code"; Message('客户价格组:%1', PriceGroupCode); end; end; - 遍历所有客户价格组:
var CustomerPriceGroup: Record "Customer Price Group"; begin if CustomerPriceGroup.FindSet() then begin repeat Message('价格组编码:%1,名称:%2', CustomerPriceGroup.Code, CustomerPriceGroup.Name); until CustomerPriceGroup.Next() = 0; end; end;
内容的提问来源于stack exchange,提问作者A. Seierup
相关产品推荐
相关产品推荐

