Workflow and ServiceDesk Community

 View Only
  • 1.  Loop in Workflow

    Posted Oct 20, 2014 05:48 AM

    Hi,

    We have created a workflow which will check for installed software in the system. We want to create a loop which will run from top to bottom for all records meeting the condition, but it should run only once. At the end of record it should exit the loop whether conditions are met or not, it should not again go into the loop.

    Need component or query which i can use to exit the loop after last record. 



  • 2.  RE: Loop in Workflow

    Posted Oct 20, 2014 05:58 AM

    Hello,

     

    there is the "For each Element in collection" component you can use to loop logic into your workflow.

     

    Iff you need an example, do not hesitate to let me know

     

     



  • 3.  RE: Loop in Workflow

    Posted Oct 20, 2014 06:07 AM

    Hi asnotb,

    I tried that but it goes back in loop. Want to end that loop in one cycle.



  • 4.  RE: Loop in Workflow

    Broadcom Employee
    Posted Oct 20, 2014 06:30 AM

    Ronak, could you maybe show a screenshot from how you are doing this?

    There are several ways of doing loops and filtering but none of them really should start over from the beginning unless you have explicitly made it that way.

    Looking at your high-level description you want to filter out some software records from a collection and then perform something on that? Sounds like you might want to use 'Configurable Collection Filter' to filter out the records meeting the condition and 'For Each Element in Collection' on remaining records. Both of which should loop only on the elements in collection.



  • 5.  RE: Loop in Workflow

    Posted Oct 20, 2014 08:26 AM

    As far as "breaking" out of a loop once a condition is met, it's fairly easy to do. I'd put a boolean on the stream right before entering the loop, set to False... the tail end of your loop condition (before looping back to the For Each comp) would then be "set boolean to True if condition met", followed by a True False rule that checks the boolean... if still false, set the path to go back into the For Each comp. If false, just "break out" of the loop and continue the flow.



  • 6.  RE: Loop in Workflow

    Posted Oct 20, 2014 08:28 AM

    Thomas,

    See there is a condition where workflow will check status as 'Job Created' and fetch software name, ticket ID from the table.

    It will then check for the installed/uninstalled software from Add/Remove programs table with install flag 1/0. If installed/uninstalled software is not found in Add/Remove table then it will increment 'Counter Value' by 1.

    Counter will be incremented till 5, then it will change status to manual.

    So the query is that if i have more than one status as Job Created in the table, so it should check each and every record having status as Job Created. If I keep the loop then it will go ON and Complete the whole workflow in one go if it didn't find software and update counter till 5 and END.

    We need to stop this loop at the end of record. so it doesn't go continously in that loop. We have kept this in monitoring mode so that it will run at specific time interval. So at every specific time interval it will check for Job Created and update counter for record not found or end if record is found.

    Thanks.



  • 7.  RE: Loop in Workflow

    Posted Oct 21, 2014 03:02 AM

    ronak8590,

    If I read you query correct, I think you are in need of

    • a new variable (new data element/type integer) that starts from 0.
    • create a for each loop
    • create an int lib with for example an sql query select

      select COUNT(displayname) from inv_addremoveprogram

      where installflag = 1 and displayname = @jobname

    • (Remember that in this case the jobname has to match the displayname of the inv table)

    • place this custom component in the loop

    • after this component, place a 'compare number rule' component that states if the count of found entries of that custom component is less than 1, there will be a +1 ('add values' component) of the new var (first line of this post)

    • after this, place for example again a  'compare number rule' to see if the new var is 5

    • if less than 5 keep looping, if the counter is 5, you can alter the path

    I don't know if I read your comment correctly but hope the above text helps you a bit. If not, be sure to let me know.

    Best regards!