Implementing FOR loop using Appian Functions

I want to implement a functionality similar to a FOR loop which runs for every item in an array where the control can be defined when to exit the loop. Also i want to return a value when it exits the loop. 

Thanks in advance

  Discussion posts and replies are publicly visible

  • You have to use looping functions, see Looping Functions section. You can't "exit" from a loop, but you can use additional conditions inside to process a value or skip it using if() function.

    docs.appian.com/.../Appian_Functions.html
  • Hi Yagyadeep, To achieve the combination that you are asking you may need an Expression Rule (with load()/with() function as per the situation) defining your loop function (could be apply() function) to a local parameter, in order to capture the result set upon applying the loop function. After that, you may need another logic inside the definition of the expression, to return the value upon completion of looping function. If you want to return only the value to be returned upon completion of the flow, it will be pretty straight forward in defining the Expression Rule. If you want to return both the looping function result set and the value to be returned upon completion, then you may need little more complexity to be incorporated in your code. Through dictionary format or anonymous CDT you may achieve the same i.e., binding 2 result sets together as one structure.
  • Thanks for your answers. I had a pretty complex requirement which involved 4 levels of nested loops in which checks are involved at various levels to end the loop. As it was turning a very complex rule to maintain and test i implemented it via a process model.
  • Starting with version 17.2, which I believe will be released tomorrow, the new a!forEach looping function will be available.  Below is a summary of some of its features.

     

     

    You can hear more about this feature by watching the 17.2 Product Announcement Webinar on the home page of Community starting at the 48 minute mark.