Genesys Cloud - Main

 View Only

Sign Up

Expand all | Collapse all

Architect Loop: Max loop count will be updated dynamically and loop iteration will be according to the updated max count

  • 1.  Architect Loop: Max loop count will be updated dynamically and loop iteration will be according to the updated max count

    Posted 27 days ago

    I am updating the max Loop count with a variable dynamically based on condition in Genesys Cloud CX architect flow. Initially max Loop count was 1. But, after first iteration I updated the max Loop count value to 2 as per condition at the end of the loop and changed the loop index to -1. So that, when the next loop will start, it's initial loop index will be 0 and iterate two more times. Max loop counter updated successfully and first iteration worked as per expectation. But, after one iteration when the loop index became 1 it stopped executing. It was supposed to be executed one more time. What is the reason of that and how can I resolve this?

    Note: Actually I need to run a loop where max loop count will be updated dynamically and loop iteration will be according to the max count.

    Attachment: 1. Starting of Loop - Max Counter Initialization || 2. End of Loop - Update Max Loop Counter and Loop Index


    #ArchitectandDesign

    ------------------------------
    Subhajit Podder
    NA
    ------------------------------


  • 2.  RE: Architect Loop: Max loop count will be updated dynamically and loop iteration will be according to the updated max count

    Posted 27 days ago
    I see an "update data" where the variable "flow.MaxLoopCount" is being assigned the same value as the variable "flow.QuestionIDs".
     
    In your loop, the value of loops is MaxLoopCount, which, as mentioned above, is flow.QuestionIDs.
     
    Is it correct to leave MaxLoopCount = QuestionIDs?


    ------------------------------
    Kaio Oliveira
    GCP - GCQM - GCS - GCA - GCD - GCO - GPE & GPR - GCWM

    PS.: I apologize if there are any mistakes in my English; my primary language is Portuguese-Br.
    ------------------------------



  • 3.  RE: Architect Loop: Max loop count will be updated dynamically and loop iteration will be according to the updated max count

    Posted 27 days ago

    Hi Oliveira,

    I assigned the count of QuestionIDs in the MaxLoopCount variable. Hence, MaxLoopCount = Count(QuestionIDs).

    Note: Your English is perfect, don't worry @Oliveira.



    ------------------------------
    Subhajit Podder
    NA
    ------------------------------



  • 4.  RE: Architect Loop: Max loop count will be updated dynamically and loop iteration will be according to the updated max count

    Posted 27 days ago

    What flow type are you using for this? There are different runtime engines depending on flow type. 



    ------------------------------
    Dave Siukola
    Sr Software Engineer
    ------------------------------



  • 5.  RE: Architect Loop: Max loop count will be updated dynamically and loop iteration will be according to the updated max count

    Posted 26 days ago

    Just out of curiosity Dave, do you mind expanding on that?

    Do you mean that the results could be different if he is doing that on an Inbound Flow or in a Workflow, for instance?

    I would like to know more about that, are there any resources that expands on those differences?

    --------

    But Subhajit, going back to your question.

    Have you tried enabling the Flow Execution History feature (Flow execution history View summary - Genesys Cloud Resource Center) to actually see what is happening to your variables step by step?

    I'm just guessing here, but maybe the "Current Index" variable (or in your case: Flow.QuestionLoopIndex) can't be updated to -1 or to any other values, since it's kind of a special variable that the system updates the value by itself every loop... I don't remember if I have ever tried that... So I can't say for sure, but the Flow Execution should be able to confirm that for you...

    Could be either that, or maybe the count for your "Max Loops" variable is actually being resulted in "1" instead of "2", which again could be confirmed with the Flow Execution feature.



    ------------------------------
    Marcello Jabur
    ------------------------------



  • 6.  RE: Architect Loop: Max loop count will be updated dynamically and loop iteration will be according to the updated max count

    Posted 26 days ago

    Hello, Marcello,

    I am asking about the flow type because there are different runtime services that run different flow types. Call flows do not run on the same engine as Workflows or Digital Bot flows for example. For the most part, the different engines try to have parity with regards to behavior, but there can be exceptions in some cases. If I know the flow type, we can get this directed to the correct team for investigation. I hope this helps.



    ------------------------------
    Dave Siukola
    Sr Software Engineer
    ------------------------------



  • 7.  RE: Architect Loop: Max loop count will be updated dynamically and loop iteration will be according to the updated max count

    Posted 21 days ago

    Hi @Marcello Jabur,

    I checked that behavior from the execution history and the MaxLoopCount was updated to 2 after first iteration. I updated the value to -1, so that the loop iteration count will be again start from zero after the first round up execution of the loop.

    Max loop counter updated successfully and first iteration worked as per expectation. But, after one iteration when the loop index became 1 it stopped executing.

    Is it really possible to update the max loop counter and control the counter index dynamically?? 



    ------------------------------
    Subhajit Podder
    NA
    ------------------------------



  • 8.  RE: Architect Loop: Max loop count will be updated dynamically and loop iteration will be according to the updated max count

    Posted 21 days ago

    @Dave Siukola I was trying it in Digital Bot Flow. Is there really any different runtime mechanism to handle loop in different flows? If yes, please share the doc that might help to debug.



    ------------------------------
    Subhajit Podder
    NA
    ------------------------------



  • 9.  RE: Architect Loop: Max loop count will be updated dynamically and loop iteration will be according to the updated max count

    Posted 21 days ago

    For the most part, the different services try to maintain the same functionality, but there have been som slight differences in implementation over the years. I don't know if those are listed in the documentation. The behavior of only resolving the max loop count at the beginning of the loop in Digital Bot Flows is consistent with the behavior for Inbound Email, Inbound Message, & Workflow types.



    ------------------------------
    Dave Siukola
    Sr Software Engineer
    ------------------------------



  • 10.  RE: Architect Loop: Max loop count will be updated dynamically and loop iteration will be according to the updated max count
    Best Answer

    Posted 20 days ago

    Hello Subhajit,

    As Dave mentioned above, this is expected as maxLoops variable is only evaluated at the beginning of the loop.

    For your use case, you could set the max loop value to something higher like 10 and then use the "Next Loop" and "Exit Loop" action to decide when to break out of the loop based on a condition.

    You also have the Loop Until action available, which allows you to branch based on conditions. Hope this helps!



    ------------------------------
    Javed Bhayla
    Staff Software Engineer - Java
    ------------------------------



  • 11.  RE: Architect Loop: Max loop count will be updated dynamically and loop iteration will be according to the updated max count

    Posted 19 days ago

    Hi @Javed Bhayla,

    Thanks for the update. Looks like Max Loop Counter is not possible to update dynamically and same is the Loop Counter Index too. Therefore, I added a condition inside the loop to break the iteration, whenever I need to update the Max Loop Counter. In the break path, I am transferring out the flow to a reusable task. In the task, based on my logics I am updating Max Loop Counter and again coming back to previous task to start the loop again with new Max Loop Counter.

    This resolved my problem. ☺️



    ------------------------------
    Subhajit Podder
    NA
    ------------------------------