I have 120 rows in array but i want to loop only first 100 rows using foreach function.
Discussion posts and replies are publicly visible
This is also covered in the Appian documentation.
I usually use the two functions that can grab a piece of the array depending on length (with a bit of effort), rDrop() and lDrop(). These both drop a part of the array from the "left end" or "right end" depending on the value passed in. It would be more straightforward if Appian had an equivalent function that lets you GET the left-or-right-most X items from an array, which would essentially be the inverse (or contrapositive?) of these two functions, and i'm unclear why they don't exist. However you can accomplish it with just a bit of effort.
local!modifiedArray: rdrop(local!array, local!originalLength - local!lengthWanted),
Mike Schmitt, please help me. What is this foreach() doing?
Stefan Helzle - in this case it's in place for demonstration. OP's question was specifically about how they'd loop through "the first X rows of a Y-length array using a!forEach()", so my example here prepares a truncated array and then feeds it into a!forEach(), which would then contain arbitrary extra functionality, not seen here.
Remember, having code that's readable, intelligible and maintainable is 100x more important than having code that's as-short-as-humanly-possible!
OK. That makes sense. Thanks :-)
© 2023 Appian. All rights reserved.