NAV 2017 - Customize Code Problem in Report

AlexLimAlexLim Member Posts: 15
Dear Nav Expert,

I have tried to find any related post about my question, however i have no luck as I not even know what keyword I should use, sorry if got similar post.

Back to question, recently I tried to add additional column in report, named as "No." and it show report line no.(example 1, 2 3... etc). You may check the sample I attached.

I use my own customize code to handle in VB(I simply don't like to pass many value from Nav to VB :D ). However some odd thing happen. When I print or preview with multiple document, result show exactly same and "No." work as i expected. But when i print in PDF or direct printer in single document, its show 4,5,6 instead of 1,2,3, more weird is preview, word and excel work correctly.

Not sure how to upload my work so i write the code here.

{ //This code is writen in VB Code
Shared LineNo as Integer
Shared ExDocNo as String

Public Function GetLineNo (CurDocNo as String)
If ExDocNo <> CurDocNo then
LineNo = 1
ExDocNo = CurDocNo
LineNo = LineNo + 1
End if

Return LineNo
End Function

{//And This code is added in new column, before Item No.

Is anyone have idea what happen? Is my code not correct or something?

Thank you.

Best Regards,

Best Answer


  • Options
    DolshaDolsha Member Posts: 41
    I advise all the calculations to carry out in DEV.

    Global variable: LineNo integer
    LineNo := 0;
    SalesInvHdr - OnAfterGetRecord():
    LineNo +=1;

    Then LineNo determine for Layout.
  • Options
    AlexLimAlexLim Member Posts: 15
    edited 2017-01-20
    Hi Dolsha & gerdhuebner,

    Thank for reply and sorry I late reply.

    The solution provided actually I used to use, but I have this idea is start from when I customize a report that required different type of sorting that cannot find in table key, and i not allow to add new key for sorting or simply add new key is too much since only use in 1 report.

    And that the problem come in, if the report have no. Then the output become not in sequence i wanted.

    As I know the sorting only can done in 2 way, key or VB. Of course this question have solution since very beginning, but just wanted know is any other option.

    Edit :
    gerdhuebner, your solution is worked, I add some simple reset code in setdata table, and its reset to no i wanted. Thank you very much. :)

    But just not understand, why its only happen in single document print out?
Sign In or Register to comment.