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
5 replies
Subscribers
7 subscribers
Views
4698 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
Hi, Have created an expression rule "increment" with one ru
vbhardwaj
Certified Senior Developer
over 8 years ago
Hi,
Have created an expression rule "increment" with one rule input "x", has the following definition :
with(
ri!x:ri!x + 1,
ri!x
)
I call this rule from another expression rule ::
with(
local!a:rule!increment(x:ri!y),
local!a
)
returns 11 if value of ri!y is 10, works fine.
But if I use the following code:
with(
local!a:rule!increment(x:ri!y),
ri!y
)
returns 10 if value of ri!y is 10.
I have two queries here :
1. Are rule inputs to expression rules Passed By Reference or Value ?
2. How can I design a rule which can return multiple values ?
OriginalPostID-167802
OriginalPostID-167802
Discussion posts and replies are publicly visible
0
vbhardwaj
Certified Senior Developer
over 8 years ago
rule!increment
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Rahul Gundu
over 8 years ago
Answer for question 1:
As per documentation, Rule inputs are used to pass data into the expression rule. (Pass by variable) approach.
To answer your 2nd question,
If you want to apply same logic for multiple inputs use apply function which will return any type array.
Otherwise, use {} and define the logic in side {}.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
rawich
over 8 years ago
@vikrantb, this is a tricky one, but also a common mistake trying to update rule inputs using with() or load() function. By defining this:
with(
ri!x:ri!x + 1,
ri!x
)
You actually created a local variable called ri!x, with value of rule input x + 1. Then you returned value of that local variable. No update made to the rule input.
We've seen this "pass by reference" magic works in SAIL expressions, but note that all the changes made to rule inputs are done in "Saving Phase" of SAIL evaluation. You can update rule inputs within saveInto of SAIL components.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 8 years ago
@vikrantb As specified above, the rule inputs are just meant for passing data might not hold valid always. As said by @rawichp they can be passed by reference especially in SAIL interfaces and because of this kind of mechanism only, we are able to update the rule inputs (which holds the reference of ACPs) in a component nested in a interface at any level.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
vbhardwaj
Certified Senior Developer
over 8 years ago
Thanks all. Understood the concept.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel