Hi All
I'm trying to insert sales invoice lines through code. When inserting dimension set ID it works if the sales invoice has one line but fails when it has more than one line. Looks like need to clear or reset in the line loop but couldn't find. Below is the code for sales line insert where dimension set is inserted:
Erro:The record in table Dimension Set Entry already exists. Identification fields and values: Dimension Set ID='0',Dimension Code='Customer Group'
DimVal.reset;
DimVal.SETFILTER("Dimension Code", '=%1', 'CUSTOMER GROUP');
DimVal.SETFILTER(Code, '=%1', SalesImportLine.U_ShortcutDimension1Code);
IF DimVal.FINDFIRST THEN BEGIN
Dim1ValID := DimVal."Dimension Value ID";
clear(TempDimSetEntry);
TempDimSetEntry.RESET;
TempDimSetEntry."Dimension Code" := 'CUSTOMER GROUP';
TempDimSetEntry."Dimension Value Code" := SalesImportLine.U_ShortcutDimension1Code;
TempDimSetEntry."Dimension Value ID" := Dim1ValID;
TempDimSetEntry.INSERT;
end;