最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

dynamics al - Business Central AL return customer default dimensions as part of customers endpoint - Stack Overflow

programmeradmin2浏览0评论

I am creating essentially an extension of the default get customer endpoint, but need to return dimensions as part of the /customers endpoint, so part() won't work for me. I presume I need to do something along the lines of this:

var
Dimensions: Text;
 
trigger OnAfterGetRecord()
var
    TDimensions: Record "Default Dimension";
begin
    TDimensions.Reset();
    TDimensions.Get();
    Dimensions := TDimensions."Dimension Code";
end;

But obviously need to pass in some "query" stuff to specify what data I want, but not really sure how. Any help is much appreciated.

Ideally I would like to have the full list of Dimensions

I am creating essentially an extension of the default get customer endpoint, but need to return dimensions as part of the /customers endpoint, so part() won't work for me. I presume I need to do something along the lines of this:

var
Dimensions: Text;
 
trigger OnAfterGetRecord()
var
    TDimensions: Record "Default Dimension";
begin
    TDimensions.Reset();
    TDimensions.Get();
    Dimensions := TDimensions."Dimension Code";
end;

But obviously need to pass in some "query" stuff to specify what data I want, but not really sure how. Any help is much appreciated.

Ideally I would like to have the full list of Dimensions

Share Improve this question asked Mar 20 at 14:56 Jack BraceyJack Bracey 531 silver badge6 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

For anyone interested in the future, this was the solution that worked for me. Thanks to Natin Verma on the Microsoft forums

var
    Dimensions: Text;

trigger OnAfterGetRecord()
    var
        DefaultDimension: Record "Default Dimension";
        DimensionText: Text;
    begin
        // Clear the Dimensions variable for each customer record
        Dimensions := '';

        // Filter Default Dimension records for the current customer
        DefaultDimension.Reset();
        DefaultDimension.SetRange("Table ID", Database::Customer); // Table ID for Customer table
        DefaultDimension.SetRange("No.", Rec."No."); // Filter by the current customer's No.

        // Loop through all dimensions for the customer
        if DefaultDimension.FindSet() then begin
            repeat
                // Append each dimension code to the text (e.g., "DEPARTMENT,PROJECT")
                if DimensionText = '' then
                    DimensionText := DefaultDimension."Dimension Code"
                else
                    DimensionText := DimensionText + ',' + DefaultDimension."Dimension Code";
            until DefaultDimension.Next() = 0;
        end;

        // Assign the concatenated dimension codes to the Dimensions field
        Dimensions := DimensionText;
    end;

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论