Hello all! I've just started an internship as a dev and am still picking up on Appian.
Currently, as part of a feature I'm developing, I've implemented an algorithm to produce a list of dates, each with consistent interval. To simplify things, I first made a helper function that produces next date based on inputs, and iterate n number of times through reduce() in the wrapper, producing following dates by feeding in previous results. This algorithm properly populates a list of dates in the expression rule test, however, there is a bit of nuance when using the algorithm to display the dates on the interface.
The problem is that the refresh condition of local variables in the helper (which is the iterated function in reduce()) is not compatible with reduce(), and the only work around is to declare each local variable as a refreshVariable() with "refreshAlways: true". The error message states that all looping functions, with the exception of forEach(), do not support variables that use any behaviour other than "refreshAlways."
Hence this leaves me wondering, is declaring each local variable with refreshVariable() necessary for a function that is iterated through reduce()? This only happens when displaying the values on the interface, which certainly has to do something with refresh conditions, but I'd like to learn more about why this happens and if there are alternative approach available.
Discussion posts and replies are publicly visible
Any chance you can share a code snippet?
As mentioned in error try using a!foreach() instead of refresh variables for each date in your list. If you need to iterate through a list looping functions are better to dynamically work on each item.
reduce() in interfaces can't handle default refresh behavior.Declare all local variables inside reduce() with a!refreshVariable(refreshAlways: true) or switch to forEach() which supports default refresh behavior.