Count the total number of times a report has been printed

robinho81robinho81 Member Posts: 48
Hello,

For creating a SSCC barcode we need to count the total number of times a report has been printed. I would like to see that the report remembers how many times it has been printed. So everytime it prints I would like the barcodenumber be raised with '1'.

Is it possible for a report to remember a value? Or do I have place the number it has been printed somewhere in a field in a table? And if it has to be placed in a field, where, which field?

Thank you!

Comments

  • matttraxmatttrax Member Posts: 2,309
    Technically a report can remember a value. It's stored in the zup file. But that is for individual users and if the zup file is ever corrupted or deleted your value goes away. So not recommended for what you want.

    You'll need to store your value in a custom field somewhere.

    You could use a number series for this. Just like orders are assigned a number from a series, your barcode could be also.
  • robinho81robinho81 Member Posts: 48
    Thank you... When I have created a starting and ending value in the series, how can I use this in my report?
  • BeliasBelias Member Posts: 2,998
    robinho81 wrote:
    Thank you... When I have created a starting and ending value in the series, how can I use this in my report?
    Why creating a serie for numbering like 1,2,3,4,5?
    see in posted invoice form, you'll see field "no. printed" in the header. just take a look at the report being printed from the print button...basically you just have to put
    myfield := myfield + 1; in the report...
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • robinho81robinho81 Member Posts: 48
    Yes I understand, but I need this report at random. Not in one loop for one specific sales order. Whenever I run this report the barcodenumber must be 1 higher than the one before..
  • BeliasBelias Member Posts: 2,998
    then create a new table with only this field and increment it whenever you run the report!
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • matttraxmatttrax Member Posts: 2,309
    I was just saying you could use a number series if you didn't want to create a custom field.

    Take a look at the insert functions for sales header or purchase header to understand how number series are initialized and used.

    Or just create a custom field and increment it.
  • BeliasBelias Member Posts: 2,998
    matttrax wrote:
    You could use a number series for this. Just like orders are assigned a number from a series, your barcode could be also.
    i've just seen this, ok! :thumbsup:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • ReinhardReinhard Member Posts: 249
    look at codeunit NoSeriesManagement (396)

    there you will see a function called GetNextNo with these parameters:
    NoSeriesCode (Code)
    SeriesDate (Date)
    ModifySeries (Boolean)

    so pass in the number series code that you have created, today's date, and TRUE for Modify Series. If you pass in false it will return the next number but not update the series
  • ReinhardReinhard Member Posts: 249
    call this function from your report. probably best at the end onPostReport. and you will have to check whether or not the user is just previewing the report:
    IF NOT CurrReport.PREVIEW THEN
    noSeriesMgnt.getNextNo(...)

    This means that the user will no longer be able to print from the preview window however.
  • robinho81robinho81 Member Posts: 48
    Thank you for your answers. I've solved it by creating a new table with one value. And in the report I rename the value to +1.
Sign In or Register to comment.