How to implement while or do while logic in expression rule?
Discussion posts and replies are publicly visible
Could you please elaborate your requirement? Why you are looking for while and do while logics?
Consider I have an integer as a input and I apply condition on that integer. If condition returns true then end of the loop, else again check the condition with decremented value of integer.
something similar like this
While(i<31)
{
if(i=15)
exit;
}
else
i--;
You cannot implement a while or a do while loop in Appian. You only have to live with a!forEach. It expects a list to operate on. This loop will run once for every item in the list.
Now to exit the loop in between, is not possible. But what is possible is to set the output value after your condition to null and then outside the loop, remove all the null values using reject() function.
There has to be some way to implement the same logic since While and Do while basic looping functionality in programming languages.
I tried any() function but it is giving me error.
Any is the looping function you can not use that.
I need looping function where condition of the loop return true or false.
In that case you have to use if condition only.
There are 1000s of such use cases. Can you be more precise, please? Because for what you mentioned, you don't even need a loop. Example -
consider i have a data which is of key(ID) value pair( fetched from database ), and value is of finite number of types and i get key as a input,.........so first i need to check the value of the key and if its what i wanted then its fine or else i need to decrement the value of the key ( previous key value pair) untill i get the desired value.
in the key value pair important is the value part.
We do not have a looping function that would stop based on a condition. All you can do is use a!forEach just like Harshit mentioned in his answer. You might have to do it in multiple steps, at least two. The first one to exclude values greater than 31, for which you can use filter, reject, wherecontains, and/or a!forEach. Second step would be to update each item in array based on the condition specified inside the while loop, for this you can use a!forEach.