RW - Adding Line Numbers to SOP Documents Example


The following example shows how easy it is to use VBA to add a line number to a SOP Document.


There is a Knowledge Base (KB) article 857285 Secure Link which uses the Line Item Sequence field and dividing its value by 16384 to obtain a line number.  This works... well ... sort of.  As soon as a line item has been deleted or inserted, the Line Item Sequence field for the lines in the document will no longer be multiples of 16384 and so this method will start producing incorrect results.  This VBA example will always work.


By adding a blank calculated integer field to the SOP Blank Invoice Form at the beginning of the line item, we can then use VBA to populate this field with a value incremented as each line is printed.  We use the Report_Start() event to reset the counter variable and then use the Report_BeforeAH() event to increment the counter variable and update the calculated field.


NOTE: To ensure that only the H2 section is incrementing the counter, we use a select case statement in the Report_BeforeAH() event.


Example code for v8.0, v9.0 & v10.0 is attached at the bottom of the article.


Please see the "Installation Instructions.txt" file in each version's archive for more information.

Line Numbers on SOP Invoice Example.zip

Comments (6)

  1. Jim says:

    Dear David,

    I need help on SOP Order Entry. I want to save the item line sequence number while user enter each item number.

    I managed to do so if NO Duplicate Item Number exists in SOP Order.

    Might I know how can I get the current line sequence number?

    Regards,

    Jim

  2. David Musgrave says:

    Hi Jim

    I have checked the code and it seems that the Line Item Sequence field is populated as soon as the line is created.

    If you add the 'Line Item Sequence' field to VBA you will be able to obtain the value.  You might need to make it visible and move it into the scrolling window first. Or use the editing of the package method described in the following post:

    http://blogs.msdn.com/developingfordynamicsgp/archive/2009/07/29/how-to-expand-the-gl-transaction-entry-scrolling-window-example.aspx

    David

  3. Jim says:

    Hi David,

    Finally, I found the 'Line Item Sequence' field in SOP Grid.

    Thanks for your help. 🙂

    Jim

  4. Sanjay Kumar says:

    I have quoted you,  you can make the conversation interesting at

    community.dynamics.com/.../232026.aspx

    PS - I have always enjoyed - envied reading your blog.

    Cheers!

    Sanjay

Skip to main content