Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
6 replies
Subscribers
7 subscribers
Views
3040 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
Is it possible to use apply() with a rule/function where the array is not the fi
Jason Ruvinsky
Certified Senior Developer
over 10 years ago
Is it possible to use apply() with a rule/function where the array is not the first parameter? Can I specify the parameters by name, rather than order, when using a looping function? (And if so, is there an example?)...
OriginalPostID-91443
OriginalPostID-91443
Discussion posts and replies are publicly visible
0
Jason Ruvinsky
Certified Senior Developer
over 10 years ago
forum.appian.com/.../Expressions
Shows how parameters can be passed by keyword, but it's not clear to me how I would do this for a looping function.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Jason Ruvinsky
Certified Senior Developer
over 10 years ago
I'm also seeing some unusual syntax that I can't find documented on the looping functions page here:
forum.appian.com/.../Function_Recipes
apply(
type!Person(firstName:_, lastName:_),
merge(pv!firstNames, pv!lastNames)
)
How do I use apply with a rule, type, or function and include the parameters by keyword? I cannot find documentation explaining how the underscores are being used here as blanks, either.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Steven Miccile
Appian Employee
over 10 years ago
One option is to create an expression rule that switches the inputs of the function so that the array is the first argument and can be applied over.
Here is some documentation on partial evaluations (underscore syntax):
forum.appian.com/.../Expressions
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Jason Ruvinsky
Certified Senior Developer
over 10 years ago
Thanks for the partial evaluation link. I've used the rule to switch input order work-around before, but I was wondering if there was a more elegant method.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Steven Miccile
Appian Employee
over 10 years ago
The more elegant method is to use partial functions. For example, if you want to apply over the index function, but you want to apply over the second parameter, not the first, you can do the following:
apply(fn!index(firstArray,_,default),secondArray)
An expression like this should apply over the second array.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Jason Ruvinsky
Certified Senior Developer
over 10 years ago
That is a very nice trick, Steven. Any chance that could be added to the looping functions documentation page as an example?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel