Global Counter

I am generating a counter to uniquely identify statements created. I have followed the method

https://learn.objectiflune.com/discourse/t/how-do-i-create-a-counter/343/1

How can I make this a global counter? That is the counter continues for running several batches of statements through several different workflows.

Hi,

I guess you need to make the value persistent by using a file; every time you increment the counter, you update the file with the latest value. If the counter has to be used for all workflows, you might use a single file.

If you need separate counters for several types of workflows or batches, you have to first identify which is the file to use.

I am not sure, if there is a way to use the workflow database for such values, but I am sure someone from OL will answer this soon.

Hello RodgerW,

Just to better understand your needs about your statements, I would like to know if you are considering as a statement each Record of your DataMapper or the documents created by your workflow processes?

Best regards

Luciano

Problem

I designed 45 document template and for each I have a workflow, i.e. 45 workflows. Most of these process a batch of line printer input data to create several bank statements for several clients and several accounts. The line printer input data comes from a legacy system which printed the statements with line printers. I split pages on FF in datamapper and in workflow I split PDF Output on account number. I need a global unique number which will assign a sequential unique number to each and every statement produced on a monthly basis for each and every account.

Soln Opt 1

I followed the tip given in “https://learn.objectiflune.com/discourse/t/how-do-i-create-a-counter/343/1”. So in the data mapper workflow I added an extra extraction step, set the mode to JavaScript, then in the editor I added record.index; I renamed this variable CNT. I put the CNT in my design template and it prints the sequential number on the statements when the process runs. But this makes the sequential number unique to that process instance only. So in one of my workflows, i inserted a task right at the start of the workflow “Set Job Info and Variables”. In this workflow task I set %1 = %u, where %u is a 15 character unique string of some sorts which appear to be unique for each instance of the process which runs from the same workflow. Back in the extraction step of the datamapper workflow I now change the javascript to:

automation.jobInfo.JobInfo1 + record.index;

Questions

  1. This method appears to generate a number which is unique to each instance of the process. Is this the best way of generating some form of global counter sequential unique number?
  2. How is the 15 character unique string generated by planet press? Is it totally random? Is it truly unique per process instance across all proceses for all workflows?
  3. First I tried using the internal job name. How does one get to these variables from the javascript in the datamapper? In general how does one get to each and any of the System variables in the javascript? Example I could not get to the job name. The documentation shows how to use automation.properties to get to some of the system variables but not all. How do I get to the other System variables in the Javascript?

Hello RodgerW

Considering that you have a workflow file with 45 processes, you can create a Global Variable in the folder “Global variables” in the “Configuration Components” section. That variable will be available for all processes you have in your workflow configuration.

You can use the “Emulated Data Splitter” plug-in to split your file by record, so that data that’s going into the Connect plug-in amounts to only one Record at a time. (important for proper indexing of the counter variable)

To increment your global variable you will need to use the plug-in “Mathematical Operations” right before the Connect plug in and as the Splitter iterates the variable will continue to increment.

For that, you can use the General configuration:

“Mathematical Expression” - %{global.variablename} + 1

“Store result in” - %{global.variablename}

Then, you can use the Automation scope within the preprocessor in the Datamapper to set a Global variable property that will grab the contents of the variable (Whatever you called it) you created in the PlanetPress Workflow tool. The name of the property needs to be the same as the name of the Global Variable in the Workflow (no prefix such as global. Is needed). If a global and a local variable have the same name ( %{myvar} and %{global.myvar} ), the local variable’s value is used and the global one is ignored, so it is important not to have a local variable with the same name as it will override the global one. To access a workflow variable inside JavaScript code within the Data Mapping Configuration, use automation.variables.variablename; . What you want to do is add an extract field with that line as the code so that you can access this data inside your design template.

If any of this still seems confusing, I suggest you to open a support call with us so we can better assist you and understand your situation more clearly.

You can either go to http://planetpress.objectiflune.com/en/resources/support and click on ‘‘report an issue’’ or you can call us at 1-866-348-5863.

Cheers!

Luciano