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

Question

Question

Token Calculator

asked on August 5, 2014

 So I have documents that have individual amounts in the fields sitting in a folder.  I want to assign that folder a template and place the totals of those values in a "total amount" field on the folder template.  I've got everything working, but I don't understand how to use the Token Calculator to add those numbers up?  I have a For Each Entry loop that is using the values to create documents, those documents are then placed in a folder.  I'm trying to use the Token Calculator, but as soon as I hit "Sum" i get the following message (see screenshot).  I thought that I would enter the "For Each Entry" current value in there so it would add them all up, but I seem to be missing something.

 

0 0

Replies

replied on August 5, 2014

SUM needs 2 or more tokens to add or a multi-value token. So you can either use the For Each Entry loop to generate a multi-value token and then use SUM on it afterwards OR you can create a Total token, then at each iteration of For Each Entry, use SUM to add the current value to the Total token.

1 0
replied on August 5, 2014

So, you're summing up the values in a multi-value field from the original document? Then just put the field token in SUM and take out the comma: SUM(%(RetrieveFieldValues_FIELDNAME_All)

1 0
replied on August 5, 2014

Miruna,

Not exactly.  I'm taking a page that has multiple transactions ($ amounts) and using QF/ZoneOCR to create multi-field values so that the 1 page has 5 amounts.  Then QF triggers my above workflow, which then takes and makes a copy of the page for each amount listed in the multi-field value (in this case 5 copies) so that each page has 1 amount assigned to it.  I would then like to be able to take the totals of those individuals pages and add them up to assign a "total" to the folder they'll be residing in.  The end user wants to be able to run a report in their accounting software to ensure that the total amount of transactions for that day match the total amount of transactions scanned into Laserfiche...so ensure there were no transactions not scanned in.

0 0
replied on August 5, 2014

Do all those documents end up in the same folder or could they be in different folders?

0 0
replied on August 6, 2014

Miruna, 

Yes, the documents all end up in the same folder due to the date of the Transacton (folders are named by date).

0 0
replied on August 6, 2014

So then wouldn't this be the same as summing up the multi-value field on the original document? Is there more than one document for any given day?

 

0 0
replied on August 7, 2014

No, because the original document which is 1 document (10 page as for example) is separated into 10 (1) page documents.  So I'd have 10  documents with individual amounts for each transaction and then a total amount on that document.  Once it hits my workflow above, the 10 documents can be transformed into 150 (1) page documents because of creating a copy for each transaction.  I need to be able to show that each individual transaction made it into that folder (which is why I need the total amount assigned to the folder based upon the documents in there).

0 0
replied on August 7, 2014

In that case, I'd write a separate workflow that runs after all the documents have been created. I'd put it on a daily schedule with a start time a few hours later. You'd have to see how long generating all those documents takes.

 

This workflow would use either Find Entries if the documents are directly in the root of the folder or Search Entries if there's a subfolder structure and get all documents in it. Then use For Each Entry to get the field values on each document and add them to a multi-value token. This way you'd rebuild the list of amounts. Once you've gone through all the documents, sum up the values in the token and set the field value on the folder.
 

0 0
replied on August 11, 2014

Miruna,

I'm having a tough time getting my workflow to do as you suggested above.  Not sure if I'm missing something, but I'm doing a retrieve field values first so that I can use the Date in my search.  I then search the repo to find all the newly created documents.  I then do the For Each Entry and Assign a Multi-Value token (which retrieves the amount from the document).  I then use a Token Calculator to (Sum up the Totals).  I then do a Find Entry to find the folder I want to assign the total to, however, my workflow keeps terminating with the following 

 

Here is my workflow:

 

0 0
replied on August 11, 2014

What are the search criteria set to?

0 0
replied on August 11, 2014

For the "Search Repository" my cretieria is as follows:

 

{[Zone OCR]} & {[Zone OCR]:[Date]>="%(RetrieveFieldValues_Date)"} & {LF:LOOKIN="BNCB\Cash Applications\ACH Batch"}

 

For the "FInd Entries" it's as follows:

 

at: \Cash Applications\ACH Batch\%(RetrieveFieldValues_Date)

0 0
replied on August 11, 2014

What is the starting entry for this workflow? In your search criteria, you want to use "equal" not "greater than or equal to" or you'll end up adding up values from multiple days.

0 0
replied on August 11, 2014

It's going to run on a schedule, so the starting entry will be those documents that are residing in the "Date" folder.  I was using the advance search syntax from the client...even if I put in 8/11/2014 to 8/11/2014 it still wants to put in the greater than or equal to because it's a date field.

0 0
replied on August 11, 2014

Workflows that run on a schedule do not have a starting entry. That's why you need the Search Repository activity to find documents to work with.

 

So you'll want to change the search criteria to:

 

{[Zone OCR]} & {[Zone OCR]:[Date]="%(Date)"} & {LF:LOOKIN="BNCB\Cash Applications\ACH Batch"}

 

This way you'll search for just the documents with the current date.

 

Move the Retrieve Field Values activity inside the For Each Entry loop (before Assign Token Values) and set it to work on the current entry instead of the starting entry.

 

0 0
replied on August 11, 2014

I'm still lost with what I assign in the Token Calculator (if anything)?  Do I even need to use that activity?

0 0
replied on August 11, 2014

Token Calculator would run the SUM function on the multi-value token you end up with after the For Each Entry loop. Then you'd use the value to set the field in the subsequent Assign Field Values.

0 0
replied on August 11, 2014

I understand that part...but my SUM function requires that I have (2) values...so I enter my "MV Token", but then I need another to enter as well.

0 0
replied on August 11, 2014

Like I said earlier on in the thread, if you have a multi-value token, just put the token in the function and take out the comma.

0 0
replied on August 5, 2014 Show version history

Ok...I'm not following it.  Sure it's easier than I'm making it.  Here is my workflow (which is what I'm using to make individual documents based upon the amount (see https://answers.laserfiche.com/questions/60412/Zonal-OCRWorkflow)

 

0 0
replied on August 5, 2014

I would create a token outside of your for each lets say TotalAmount (set to 0) then in your for each have a token calculator named tempTotalAmount that has this expression

%(TotalAmount) + %(individualAmount)

then use an assign token value to set TotalAmount = tempTotalAmount (still inside your for each)

When your for each is done your total value should be in the TotalAmount token

0 0
replied on August 7, 2014

Hi Daryl,

 

It becomes easier, if all documents are stored in that particular date folder of the transaction.

When Folder is created, assign a template with Total Amount, which is by default 0.

 

When new document is scanned, let the workflow run by duplicating the pages, based on the number of amount found, during the for each, add all values together using token calculator or Assign Token Values.

 

If you use Token Calculator, It can be used either before or after for each by using SUM(%(RetrieveFieldValues_IndividualAmount_All). 

IF you use Assign Token Values, create a token value called Total, then Within For each Add %(Total) + %(FieldName#[%(ForEachValue_Iteration)]#). Later after for each, retrieve parent folder's Field value and Add the %(Total)  + %(Retrieved_Values_TotalAmount), and Assign value to Total Amount Field.

 

 

 

 

 

 

0 0
replied on August 7, 2014

This is not a reliable solution because of Workflow being multi-threaded. As Quick Fields stores the documents, Workflow will pick them up and start an instance for  each one. Some of these instances can run concurrently, so they may end up reading the Total Amount value from the folder at the same time. So 2 separate instance may work with the same starting value and add to it independently. The last one setting the field value back on the folder would win and the results of the first would be lost.

 

Granted, Quick Fields is sending the documents one at a time, so the chance of that happening is low, but with sufficient load on the Workflow Server, it is still possible.

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

Sign in to reply to this post.