You are viewing limited content. For full access, please sign in.

Question

Question

How to have a counter in Workflow which increments a number and loads it in the form for each new submission?

asked on September 15

Hello Laserfiche Community,

I need help implementing an auto-incrementing document numbering system in Workflow. I'm relatively new to Laserfiche Workflow, so I'd appreciate detailed guidance.

Requirements:

  • Document number format: L26-0001
    • "L" = constant prefix
    • "26" = last 2 digits of current year (2026 = 26, 2027 = 27, etc.)
    • "-" = separator
    • "0001" = 4-digit sequential number that increments with each submission
    • Last 4 digits could go up to "9999"

Business Logic:

  • Numbers should increment sequentially: L26-0001, L26-0002, L26-0003...
  • The counter should reset to 0001 when the year changes
  • Each year maintains its own sequence (L26-0001, then L27-0001 the following year)
0 0

Answer

SELECTED ANSWER
replied on September 15

Easiest way to implement this depends on how you use the repository and metadata, but this is the approach I would take.

Repository Structure

X Department Cases

  • 📁 2026
    • 📁 L26-0001
    • 📁 L26-0002
    • . . .
  • 📁 2025
    • 📁 L25-0001
    • 📁 L25-0002

Each of the year folders can have template metadata set for the "next available doc number"

Workflow runs and finds the year folder by year

  1. current year doesn't exist -> create it and add field "next available doc number" = 1
  2. Current year does exist
    1. save "next available doc number" to workflow variable
    2. immediately set "next available doc number" to # plus 1.
      1. small intricacies getting the 0's padding but its trivial
  3. create the document's folder named L26-000X in the repository
    1. When creating the document if a LXX-X doc already exists
    2. get the "next available doc number" value again
    3. if it fails again suspend the workflow (you have too many things happening simultaneously
  4. Store any related docs under the folder
  5. save the doc number as a metadata field for any related docs as well

 

The year folder structure is useful for the doc numbering you need and for records management purposes if you're using it. You can change the field security of the "next available doc number" field so only workflow/admins can change it.

 

1 0
replied on September 16

Thank you this helps a lot

0 0

Replies

replied on September 15

Please help! Need to find a fix to this

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.