I have a gridtextColumn with a local variable to store the datasubset value obtained from a query. I am trying to build a link to a record for that column on all rows of the grid. I used apply function with a proper rule and index function along with it. But for some reason it does not work.
a!gridTextColumn( label: "Id", field: "Id", data: index(local!datasubset.data, "Id", null), links:apply(rule!POC_getRecordLink(), index(local!datasubset.data, "Id", null)) )
It gives me an error -->
Interface Definition: Expression evaluation error at function 'apply' [line 33]: A rule or function reference is expected as the 1st parameter.
Although I have put the rule as you can see? Any idea then why this error?
Discussion posts and replies are publicly visible
Is there any particular reason you're still using apply() instead of a!forEach()?
No particular reason.
a!forEach() worked. Thanks.
Cool - a!forEach is generally more flexible as well as more powerful while still being easier to understand overall.
As far as why your original code didn't work - my first guess is that when you reference a rule with apply() without specifying parameters, you need to invoke the rule name without the () at the end. so more like this:
apply( rule!myRule, local!myList)
That's exactly right, Mike. If you include the parentheses, you also have to use partial evaluation to show the code where the array of items are supposed to be input as parameters one at a time.
apply(
rule!myRule,
local!myList
)
does the same thing as
rule!myRule(_),
You need the underscore, otherwise you make it look like you're applying a rule with no parameters to a list, which doesn't make any sense.
Is the time complexity of a!apply and a!forEach is same? or apply is like map function in appian with time complexity O(1)?
sanjuktab2257 said:Is the time complexity of a!apply and a!forEach is same?
If you just mean execution time, I've never heard any reputable evidence that a!forEach() is any measurable amount slower than apply(), even in stress tests. But you could always devise your own stress test and compare, I guess.
Thanks Mike!
I just did a stress test, a!apply took 4ms where as a!forEach took 21ms