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
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;
Hi All
I am also the same issue in BC Cloud with AL Need solution.
Hey Farzad ,
Did you already have a sollution for this ? We're having the same issue in BC cloud with AL Code
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?
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
Hi Javed Akhtar,
It is record 352 Default Dimension.
Hi Suresh Sir ,
TempDimSetEntry.VALIDATE("Dimension Code",DefDim."Dimension Code");
TempDimSetEntry.VALIDATE("Dimension Value Code",DefDim."Dimension Value Code");
what is the DefDim record??
@AftabHussain,
Default Dimension table
What is
DefDim?
I also have this problem, thank solved my problem now :)
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,888 Super User 2024 Season 2
Martin Dráb 229,247 Most Valuable Professional
nmaenpaa 101,156