Passing the count result value? | Community
Skip to main content
Level 4
February 14, 2024
Question

Passing the count result value?

  • February 14, 2024
  • 1 reply
  • 1266 views

Hi everyone,

 

I'm a bit puzzled with this issue, so I would appreciate any advice how to fix it. 

 

In one of the flows, I filter out specific results and count them with iterator (increment function), then store in the variable. For example, I have 5 bundles meeting the filter criteria and thus I have 5 bundles in stored variable.

Then I need to use this result value in another flow, so I use Get variable module to access it, but for some reason I get number 4 here, instead of 5. I'm not sure what I'm missing here. 

How can I get the right result (i.e. 5 in this case)? Any ideas?

 

Could you please advise?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

Level 5
February 15, 2024

It sounds like you have a reference problem that is specific to the scenario.  If you can post more details, it might be possible to debug.

But I suspect you're not updating the reference inside the iterator.  Note that Fusion uses pass by value and not pass by reference.  Check this out:

I've also attached this scenario to the thread.  You can import it as a test if you want to see how it works.

vioviAuthor
Level 4
February 16, 2024

Thank you for your suggestion, I really did not explain well what I'm trying to achieve.

 

Simply speaking, I need to fetch the count result (or just number of bundles). I need to know how many bundles meet this filter criteria and then I could use it, for example, in a note: "5 bundles went route A, 3 bundles went route B", It would be even better to have total number of bundles too.

 

This is just one part of a bigger scenario. In this part (before count), we search data in datastore, then we create csv for one flow and then in another (in this branch) we parse CSV, set variables and process this info for sending out notifications and adding data to the report.

As you may see in the example below, we have 5 bundles coming out of Set variables module and then they meet the filter criteria and go to the "Success" branch, where I try to get this count number (just a number of bundles coming here).

Is there a way to fetch it?

 

 

 

Level 5
February 16, 2024

 

I would set counters, one per branch, and then -- inside the branch -- get the counter ref for the specific branch and increment it.  Once you're outside all the branches, then you can get all the counter refs again for the resulting numbers.