Workflow Soluiton

 View Only
  • 1.  Simple Counter Within a Filter

    Posted Oct 06, 2014 11:24 AM

    I have count variable that I need to increment by 1 each time a certain condition is met within a configurable collection filter, then I need that variable to be available outside the filter.

    Which component would I use to increment, and do I need to set the count variable as global so it can be acessesed from outside the filter?  (As to my understanding, the only output variable in the filter are the records that were kept in the collection).

    Thanks for helping with my beginner questions...



  • 2.  RE: Simple Counter Within a Filter

    Posted Oct 06, 2014 11:58 AM

    I normally use Initialize Data at the front of my workflow, create an integer variable called "CounterValue" or something similiar, give it a value of 0 (or 1, depending on your model).  Within your loop, when your evaluation proves true, use the "Add Values" component to add the integer 1 to the variable.

    let me know if you need a test model to visualize it, or more information.

    -andrew



  • 3.  RE: Simple Counter Within a Filter

    Posted Oct 06, 2014 12:41 PM

    You could do what africo said above, or you could make it global. Just remember to reset it back to 0 if needed when you have to in either case using a Add New Data Element/Initialize Data comp (you can use Add New Data Element to reset the val even though it isn't technically "new", just reuse the same name)



  • 4.  RE: Simple Counter Within a Filter

    Posted Oct 06, 2014 01:57 PM

    Thanks Andrew, the "Add Values" is exaclty what I was looking for.



  • 5.  RE: Simple Counter Within a Filter

    Posted Oct 06, 2014 02:35 PM

    Reecardo, is making a global variable that can be incremented inside an embedded model then displayed back in the main model just a matter of adding it to the Global Variables at the project level?  Would I still need to initialize them somewhere else?  Thanks!



  • 6.  RE: Simple Counter Within a Filter

    Posted Oct 06, 2014 02:40 PM

    Global variables are added in Project properties, like you said. And I believe the initial value can be set there as well. Once added to global vars, it should be able to be referenced by any component (it is prefaced with [Global])

    One caveat... global vars, in general, are considered bad programming practice from a programmer's perspective, at least when a locally managed var can suffice. However, if you manage it properly, there's no reason a global var can be used in this case.
     



  • 7.  RE: Simple Counter Within a Filter

    Posted Oct 06, 2014 03:27 PM

    Hi Reecardo, if I don't use global variables, how can I pass the value of the counter variable within the configurable collection filter to other components?  Thanks.



  • 8.  RE: Simple Counter Within a Filter

    Posted Oct 07, 2014 07:35 AM

    The only way you can have the counter variable available to other components is to either have a global variable, have a variable added upstream (like africo said), or haave the variable be part of the input to the model.