Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)
Answered

How to set dimensions in C/AL

(0) ShareShare
ReportReport
Posted on by

Hi all

I am in the process of making a customized module which has a function that creates a new sales order. This function works fine, but I do not know how to add dimensions to this new sales order via C/AL.

I have setup 3 shortcut dimensions and I would like to add values for those 3 for the sales order.

My first thought was to add 3 records to Dimension set entry table (one for each dimension), but then I found out that I also need to add records to Dimension set tree note table. There must be a an easier way to do this. maybe by using CU 408 - dimension management?

If someone could give me an example of how to do this it would be greatly appreciated 

Thanks

*This post is locked for comments

  • Muhammad Arif Maseed Profile Picture
    782 on at
    RE: How to set dimensions in C/AL

    Here is the solution for Business Central

    local procedure CreateDimensions4(DimensionCode: Code[20]; DimensionSetValue: Code[20]; DimensionSetID: Integer): Integer

       var

           DimSetEntry1: Record "Dimension Set Entry";

           recDimSet: Record "Dimension Set Entry" temporary;

           DimSetEntry: Record "Dimension Set Entry";

           DM: Codeunit DimensionManagement;

           dimSetID: Integer;

           dimSetIDn: Integer;

           TryV: Integer;

       begin

           dimSetID := 0;

           recDimSet.RESET();

           IF recDimSet.FINDSET() THEN

               recDimSet.DELETEALL();

           recDimSet.RESET();

           recDimSet.INIT();

           recDimSet.VALIDATE(recDimSet."Dimension Code", DimensionCode);

           recDimSet.VALIDATE(recDimSet."Dimension Value Code", DimensionSetValue);

           recDimSet.INSERT();

           if DimensionSetID = 0 then begin

               dimSetIDn := 0;

               dimSetIDn := DM.GetDimensionSetID(recDimSet);

           end

           else

               dimSetIDn := DimensionSetID;

           DimSetEntry1.RESET();

           // DimSetEntry1.SETFILTER(DimSetEntry1."Dimension Set ID", '%1', dimSetIDn);

           IF DimSetEntry1.Get(dimSetIDn, recDimSet."Dimension Code") THEN

               TryV := 1

           ELSE

               IF recDimSet.FINDFIRST() THEN

                   REPEAT

                       DimSetEntry.RESET();

                       DimSetEntry.INIT();

                       DimSetEntry.VALIDATE(DimSetEntry."Dimension Set ID", dimSetIDn);

                       DimSetEntry.VALIDATE(DimSetEntry."Dimension Code", recDimSet."Dimension Code");

                       DimSetEntry.VALIDATE(DimSetEntry."Dimension Value Code", recDimSet."Dimension Value Code");

                       DimSetEntry.INSERT();

                   UNTIL recDimSet.NEXT() = 0;

           exit(dimSetIDn)

       end;

  • Muhammad Arif Maseed Profile Picture
    782 on at
    RE: How to set dimensions in C/AL

    Hi All

    I am also the same issue in BC Cloud with AL Need solution.

  • DannyDycom Profile Picture
    5 on at
    RE: How to set dimensions in C/AL

    Hey Farzad ,

    Did you already have a sollution for this ? We're having the same issue in BC cloud with AL Code

  • Farzad Profile Picture
    15 on at
    RE: How to set dimensions in C/AL

    Hi Guys

    I'm using Business Central on the cloud, I do all of the suggestion and they work for me, apart from last step which is updating the "Dimension Set ID".

    it just doesn't get the integer value! and it becomes zero.

    I know the number is correct because I see other rows that they have the same value (generated by UI)

    any idea?

  • Moon Profile Picture
    215 on at
    RE: How to set dimensions in C/AL

    Hello Suresh,

    I'm trying to get not set Dimensions and print them in a MESSAGE method, for each line in the Purchase Invoices Page. Could you help with some example C/AL to to get these dimensions for the Purchase Lines table? I know enough to get around with C/AL but not how to do this. I know to get the Dimension Set ID with 408, but having trouble getting the values after.

    thank you

  • 4BzSoftware Profile Picture
    6,073 on at
    RE: How to set dimensions in C/AL

    Hi Javed Akhtar,

    It is record 352 Default Dimension.

  • javedakhtar Profile Picture
    1,751 on at
    RE: How to set dimensions in C/AL

    Hi Suresh Sir ,

    TempDimSetEntry.VALIDATE("Dimension Code",DefDim."Dimension Code");

    TempDimSetEntry.VALIDATE("Dimension Value Code",DefDim."Dimension Value Code");

    what is the DefDim record??

  • Rafael B. Profile Picture
    715 on at
    RE: How to set dimensions in C/AL

    @AftabHussain,

    Default Dimension table

  • AftabHussain Profile Picture
    5 on at
    RE: How to set dimensions in C/AL

    What is 

    DefDim?
  • Community Member Profile Picture
    on at
    RE: How to set dimensions in C/AL

    I also have this problem, thank solved my problem now :)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,208 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,970 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans