Updating Dim 3 on General Journal

sunnyksunnyk Member Posts: 280
Hello,
How can we update DIM 3 on Journal Lines using process report?

Best Answer

  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    Answer ✓
    You need to find if a Dimension Set ID already exists for your dimension combination (including changed Shortcut Dimension 3), if not create it, and then update journal line with new dimension set id
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03

Answers

  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    Answer ✓
    You need to find if a Dimension Set ID already exists for your dimension combination (including changed Shortcut Dimension 3), if not create it, and then update journal line with new dimension set id
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • YuryYury Member Posts: 59
    CLEAR(RecNo);
    GenJnlLine.RESET;
    // set any filters you need
    GenJnlLine.SETFILTER(...);
    
    TotalRecNo := GenJnlLine.COUNT;
    Window.OPEN('@@1@@@@@@@@@@@@@');
    IF GenJnlLine.FINDSET THEN
      REPEAT
        // get new dimension value
        MyNewShortcut3DimensionValue := 'ANY NEW VALUE YOU NEED';
    	
        // update shortcut from line2line
        RecNo += 1;
        Window.UPDATE(1,ROUND(RecNo / TotalRecNo * 10000,1));     
        DimSetEntryTemp.RESET;
        DimSetEntryTemp.DELETEALL;
        DimMgt.GetDimensionSet(DimSetEntryTemp,GenJnlLine."Dimension Set ID");
        DimSetEntryTemp.RESET;
        DimSetEntryTemp.SETRANGE("Dimension Code",GLSetup."Shortcut Dimension 3 Code");
        IF NOT DimSetEntryTemp.FINDFIRST THEN BEGIN
          DimSetEntryTemp.RESET;  
          DimSetEntryTemp.INIT;
          DimSetEntryTemp."Dimension Set ID" := GenJnlLine."Dimension Set ID";
          DimSetEntryTemp.VALIDATE("Dimension Code",GLSetup."Shortcut Dimension 3 Code");
          DimSetEntryTemp.VALIDATE("Dimension Value Code",MyNewShortcut3DimensionValue);
          DimSetEntryTemp.INSERT(TRUE);
          GenJnlLine."Dimension Set ID" := DimMgt.GetDimensionSetID(DimSetEntryTemp);
          GenJnlLine.MODIFY;
        END
        ELSE BEGIN
          DimSetEntryTemp.VALIDATE("Dimension Value Code",MyNewShortcut3DimensionValue);
          DimSetEntryTemp.MODIFY(TRUE);
          GenJnlLine."Dimension Set ID" := DimMgt.GetDimensionSetID(DimSetEntryTemp);
          GenJnlLine.MODIFY;
        END; 
      UNTIL GenJnlLine.NEXT = 0;
    Window.CLOSE;
    
    MESSAGE('Complited');
    
    Regards,
    Yury
Sign In or Register to comment.