Value Posting field in Default Dimension table

silverferretsilverferret Member Posts: 7
I am importing Items via a dataport. After some help from a previous post, the VALIDATE is creating the correct entry in the DefaultDimension table, however, the "Value Posting" field is not populated.

I see that VALIDATE is creating the DefaultDimension record, but then would I need to select it and MODIFY?

Here is the code I am currently using. Thanks in advance for any help.
ITEM - OnAfterImportRecord()

    Item.INIT;
    Item."No." := varNo;
    Item.INSERT;

    "Item Unit of Measure".INIT;
    "Item Unit of Measure"."Item No." := varNo;
    "Item Unit of Measure".Code := varUnit;
    "Item Unit of Measure".INSERT;

    Item.VALIDATE ("Global Dimension 1 Code", varGlobalDim1Code);
    Item.VALIDATE ("Base Unit of Measure", varUnit);

    Item.MODIFY;

Comments

  • krikikriki Member, Moderator Posts: 9,110
    You don't need to do it, because the function "ValidateShortcutDimCode" called in the OnValidate-trigger of field "Global Dimension 1 Code" there is a MODIFY of the Item-record.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • silverferretsilverferret Member Posts: 7
    I am a total newbie to NAV, so apologies if I am asking redundant questions.
    You don't need to do it, because the function ...

    I must have to do something because right now the Value Posting field is not getting populated. According to the data team here, they would like to see a value of 2 in there.

    So I would think that either I need to code for this, OR I need to have something setup somewhere that the validation can draw from in order to determine what value really goes in that field. Right?
  • krikikriki Member, Moderator Posts: 9,110
    In Codeunit 408:"DimensionManagement", in function "SaveDefaultDim" change the code as follows:

    This code will give the value "Same Code" for the dimension 1 used in the Item table.
    END ELSE BEGIN
        DefaultDim.INIT;
        DefaultDim.VALIDATE("Table ID",TableID);
        DefaultDim.VALIDATE("No.",No);
        DefaultDim.VALIDATE("Dimension Code",GLSetupShortcutDimCode[FieldNumber]);
        DefaultDim.VALIDATE("Dimension Value Code",ShortcutDimCode);
    
    //> EXTRA CODE BEGIN
        IF TableID = DATABASE::Item THEN
          IF fieldNumber = 1 THEN
            DefaultDim."Value Posting" := DefaultDim."Value Posting"::"Same Code";
    //< EXTRA CODE END
    
        DefaultDim.INSERT;
        RecRef.GETTABLE(DefaultDim);
        ChangeLogMgt.LogInsertion(RecRef);
      END;
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.