Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)
Answered

How to set dimensions in C/AL

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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

  • 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;

  • 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
    DannyDycom 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
    Farzad 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
    Moon 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
    4BzSoftware 6,071 on at
    RE: How to set dimensions in C/AL

    Hi Javed Akhtar,

    It is record 352 Default Dimension.

  • javedakhtar Profile Picture
    javedakhtar 1,745 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
    Rafael B. 715 on at
    RE: How to set dimensions in C/AL

    @AftabHussain,

    Default Dimension table

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

    What is 

    DefDim?
  • Community Member Profile Picture
    Community Member Microsoft Employee 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,419 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,492 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans