Solved

Unable to Access Calculated Variables


Badge +4

 Hello! 

I am having trouble accessing a calculated variable in a workflow. Here is what I am trying to do.

We have an employee incentive program which gives employees points to use based on performance. We are creating a workflow that sends them an email letting this know how many points they have available for use. 

 

We have two lists USERS which contains info like, Name, Email and PERNER (Employee ID). We have a second list called AGENT  POINTS that contains info like point bucket (Basically Total Points) and PERNER.

The issue comes from calculating total points.. Each PERNER has several items in AGENT POINTS that need to be added together to create the total sum of points available for that particular PERNER (Employee). 

We have gotten the workflow to successfully match the PERNER with Name, Email  however when it is time to calculate the Total Points the variable returns as for every Employee. I am attaching screen shots of the workflow below.

 

 

 

I will say that I know that it is not a configuration issue with the Second query list value because when I click “RUN NOW” and update the Workflow Variable manually the Query returns the expected values for each PERNER I’ve highlighted the manual entry I mad and the result 

 

 

icon

Best answer by Edmon 2 August 2023, 15:02

View original

23 replies

Userlevel 5
Badge +13

You should be able to calculate the Total Points by looping through each point value in the collection and adding that induvial point value to a total points value variable.  Here is an example:

  1. Add a For Each action to the workflow with Target Collection = var_BucketTotal_Collection and “Store Result in” = numCurrentPointValue (workflow variable of number type).
  2. Inside the For Each action, add a Math Operation action.
  3. Create a workflow variable of Number type called numTotalPoints (or whatever you like). 
  4. Configure the Math Operation action as:
    Calculation Workflow Date numTotalPoints
    Plus
    Workflow Date numCurrentPointValue
    Store result in numTotalPoints
  5. This will give you a sum of all the points in the numTotalPoints variable and you can use that in elsewhere the workflow.

 

Badge +4

You should be able to calculate the Total Points by looping through each point value in the collection and adding that induvial point value to a total points value variable.  Here is an example:

  1. Add a For Each action to the workflow with Target Collection = var_BucketTotal_Collection and “Store Result in” = numCurrentPointValue (workflow variable of number type).
  2. Inside the For Each action, add a Math Operation action.
  3. Create a workflow variable of Number type called numTotalPoints (or whatever you like). 
  4. Configure the Math Operation action as:
    Calculation Workflow Date numTotalPoints
    Plus
    Workflow Date numCurrentPointValue
    Store result in numTotalPoints
  5. This will give you a sum of all the points in the numTotalPoints variable and you can use that in elsewhere the workflow.

 

Hey, thanks for your help! 

 

I have this configuration in my workflow already. For some reason it is not working when it’s time to use the variable. Like above, the Query List works fine but when I go to use the variable it  spits out 0 for everyone.

 

It leads me to believe these specific operations are in the wrong place in the workflow. I’ve attached pictures on my original post. Do you see anything that might cause challenges there? 

Userlevel 5
Badge +13

What type of field is the PERNER field?

I do not see the action(s) that perform the calculations in your workflow screenshots. Can you show more of what’s inside the For Each loop?

Badge +4

Sorry, I sent the wrong screenshot! 

 

Here is how the workflow is laid out. 

 

 

This is how the first “For Each” loop is configured. 

 

 

Here is how the second for Each Loop is configured.  

 

 

 

PERNER is stored as a “Single Line of Text” as no calculations will be done to it 

Userlevel 5
Badge +13

Thanks for the screenshots. Can you also add a screenshot with the Filter section expanded in the Query List action?

Badge +4
This is for the second query action in the workflow! Thanks again!

 

Userlevel 5
Badge +13

One last screenshot. Could you also provide the configuration of the Math Operation action?

Badge +4

Sure, 

 

 

Userlevel 5
Badge +13

Try adding a “Log in history list” action in the second For Each loop and placing the var_BucketTotal variable in it to make sure you’re getting values there. That should provide a piece of the puzzle to help troubleshooting to making sure there is data there.

Badge +4

Try adding a “Log in history list” action in the second For Each loop and placing the var_BucketTotal variable in it to make sure you’re getting values there. That should provide a piece of the puzzle to help troubleshooting to making sure there is data there.

I’m not sure if this is where I go to review the Log In History Action but there is nothing there.

This is what I see 

 

Here is how it was configured 

 

 

Userlevel 5
Badge +13

Which version of Nintex Workflow are you using?  Is this a site workflow or list workflow?

Badge +4

This is a Site Workflow

 

This is version:  5.2.1.30

Userlevel 5
Badge +13

Thanks for the info.

To view the site workflow history, click on the settings gear/cog on the top right of the page, select Nintex Workflow, click the Nintex Workflow options drop down, and select Workflow history.

If there is no message from the Log in History List action, this could mean something like the workflow has not been published with this action in it or no items are returned in the collection for the second For Each action to use.

Badge +4

Thanks for the tip 

 

I was able to access this history and there was nothing recorded.

I did however notice that it appears that the calculation action is not event taking place.

 

Everything here is green except the two actions in the For Each loop. see below. I have no clue why that is happening. 

 

Userlevel 5
Badge +13

After the second Query List action and before the second For Each action, add a Collection Operation action and configure that with the Count option. Store the count in a variable and log that to the workflow history. If that comes back as a count of 0, then the Query List action is not returning any data.

Badge +4

Just ran it again. It is the same, No count displayed and that particular section is still not green like the others

Userlevel 5
Badge +13

Looks like the inner second Query List action is not returning anything. That points to the filter not configured properly.

Try adding another Log in History List action right before the inner second Query List action and configure it to write the var_ActivePerner variable value to history. The results there should narrow down where the issue is happening.

Badge +4

Morning! I just ran it again with the History List action and there is nothing there.

 

I’m looking at the workflow and I think I see the issue. My first “For Each Loop” targets the Users Collection but then stores the result of the For Each loop in var_ActivePerner. Is the issue that I am trying to access var_ActivePerner inside the For Each loop that defines it? 

If you think that might be the case, do you have any ideas on how to rearrange the workflow? 

Userlevel 5
Badge +13

First thing is to make sure that the var_ActivePerner variable actually contains data before going into the second For Each loop. To test that, add a “Log in history list” containing the var_ActivePerner value right before the second inner For Each action. This will give a clue to what might not be working. If that is empty, then the second inner Query List action will not return anything. If it is filled, then the filter in the Query List action might need updating.

Badge +4

I just followed those steps and this is what I  got 

 

There is data being fed into the For Each action

 

I also noticed this. 

 

 

 

This is a very interesting issue.

 

Thanks again for all of your help, hope you’re having a great day thus far!

Badge +4

This is solved. The issue was the fact that PERNER had commas in it therefore it was not being recognized by the Query List Filter. Toggling off the “XML encode inserted tokens” fixed the issue. 

Userlevel 5
Badge +13

That’s exactly where we were narrowing the issue down to. Returning zero items in the second Query List action pointed to the filter values not being equal. Glad you were able to figure it out!

Badge +4

That’s exactly where we were narrowing the issue down to. Returning zero items in the second Query List action pointed to the filter values not being equal. Glad you were able to figure it out!

Thanks so much for you help! :) 

Reply