Workflow to Create a Running Total


Badge +3

I need to create a workflow which looks at 'ListA' loops through pending amounts and awarded amount, adds those together and then populates 'ListB' with the total.

I have tried doing this with a site workflow but cannot get the one column in List B to populate with the value.

Any help would be gratefully received


9 replies

Userlevel 5
Badge +14

there shouldn't be a problem to create/update an item in list from site workflow.

can you post configuration of your action and describe what problem/error do you experience?

Badge +3

HI Marian,

I have two lists as mentioned they are for funding.  User enters item in list a and this will either have a fund request, or fund award.  List B will contain the running Fund Total which will be Request + Award.

the Site workflow is:

Query List - Query List A two collection variable colPending & colAwarded

For Each - Target Collection = colRunningTotal - store result in varFinalAmount

Collection Op - colAwarded (count) - store in varAwarded

Collection Op - colPending (count) - store in varPending

Update Item - Update 'Total Funding Amount' (ListB) Where - Total Awarded equal 'workflow data' varAwarded

field to update - workflow data - varAwarded

The workflow runs fine and doesn't throw any errors but fails to update the figure in  list b

Please let me know if you need any more info

Userlevel 5
Badge +14

For Each - Target Collection = colRunningTotal - store result in varFinalAmount

where do you pouulate colRunningTotal collection? as you've writen you populate two other collections within query list action ...

is it collection meant to store result(s)? is it empty then?

if so, for each loop is not executed.

Collection Op - colAwarded (count) - store in varAwarded

Collection Op - colPending (count) - store in varPending

count operation returns number of elements within the collection, aka. number of items query list action returned.

in your original post you mentioned you want to sum up amounts, so I would expect kind of summary action.

so, for each loop in your setup is not executed, hence your varAwarded  variable is not updated.

if you haven't initialized it, it's empty and that empty value is written to the list field.

Badge +3

Hi Marian,

Are you able to help me with writing the workflow so that I can get a running total?

Thanks

Userlevel 5
Badge +14

something like this should work.

set variable varTotalPendingAmnt  = 0

set variable varTotalAwardedAmnt = 0

Query List - Query List A two collection variable colPending & colAwarded

For Each - Target Collection = colPending  - store result in varCurrPendingAmnt, store index in varIdx

Math Op - varTotalPendingAmnt = varTotalPendingAmnt + varCurrPendingAmnt

Collection Op - target collection = colAwarded, Get operation, index = varIdx, store result in varCurrAwardedAmnt

Math Op - varTotalAwardedAmnt = varTotalAwardedAmnt + varCurrAwardedAmnt

-- End of loop

Update Item - here I'm not sure, do you want to create new iten in LIstB or do you want to update existing item?

if you want to make an update, how do you identify which item(s) to update?

Badge +3

Hi

Badge +3

I need to update list being with the running totals of the amount pending and the amount awarded which I could then have these amounts coming off the Total Fund so I can then get a running total of what money is left in the fund

Userlevel 5
Badge +14

so use 'update item' or 'update multiple items' actions.

I'm not what sure what's the question here...

Badge +1

Sorry, I am new to the Community Forum.  I don't know if this issue is closed and cannot be revisited.  But I'll give it a shot.

 

I think I am trying to accomplish what the original poster described.  I am trying to create a workflow for a travel approval process.  I need to keep a running total of trip estimated costs(provided by the traveler when they request approval) and a running tally of  actual costs incurred (amount provided by the traveler post travel).    I need to create a workflow which looks at 'ListA' loops through estimated travel costs and actual travel costs, and then populates 'ListB' with the totals.

 

I tried to replicate the advice provided to the previous poster.

 

Site workflow is

 

set variable varTotalEstimatedAmnt  = 0

set variable varTotalActualAmnt = 0

 

Query List - Query List A two collection variable colEstimated & colActual

 

For Each - Target Collection = colPending  - store result in varCurrEstimatedAmnt, store index in varIdx

 

Math Op - varTotalEstimatedAmnt = varTotalEstimatedAmnt + varCurrEsitmtedAmnt

 

Collection Op - target collection = colActual, Get operation, index = varIdx, store result in varCurrActualAmnt

 

Math Op - varTotalActualAmnt = varTotalActualAmnt + varCurrActualAmnt

-- End of loop

 

Update Item

 

The workfow runs but I can't get that running total.  Thanks if you are able to help.

 

Reply