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
+1
person also asked this
people also asked this
Replies
7 replies
Subscribers
8 subscribers
Views
2974 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
Need to understand how this rule is defined in the attachment. Does the item[ ]
nikhilh0001
over 9 years ago
Need to understand how this rule is defined in the attachment. Does the item[ ] refer to ri!item or is it some array object?
OriginalPostID-146357
OriginalPostID-146357
Discussion posts and replies are publicly visible
Parents
0
chetany
A Score Level 1
over 9 years ago
Hi, I found how the rule works. In The item[], the item is the same as rule input. Now copy paste the below code into interface designer(just for verifying..)
Please define a rule input called 'item' with Any Type.
a!dashboardLayout(
firstColumnContents: {
a!textField(
label: "Test",
value: rule!CASE_APP_randomItemFromArray(item: ri!item)
)
}
)
To Test it out, let us assume you have employee cdt and DS with some fields in employee cdt like id, fname and lname. Also assume that you have a query rules like getEmployeeById(id) which returns the specific employee based on id. I am assuming you have atleast 5 records of employee in DS.
Now Test this rule in interface designer. While gving the input in interface designer, give the input like this: {getEmployeeByid(1), getEmployeeByid(2), getEmployeeByid(3)}
Each time you execute/test this rule, you will get a different output. In short, the above rule just takes an array of "items", where items can be any type of CDT.(might be something other than employee, this is just an example.). This rule then selects a random 'item' i.e random CDT from the input array and returns it.
Now, the same rule definition in screenshot can be rewritten as :
=ri!item[rule!CASE_APP_random(length(ri!item))] instead of
=item[rule!CASE_APP_random(length(ri!item))]
It does not change the meaning. It just returns a random cdt from the passed array of cdts.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Reply
0
chetany
A Score Level 1
over 9 years ago
Hi, I found how the rule works. In The item[], the item is the same as rule input. Now copy paste the below code into interface designer(just for verifying..)
Please define a rule input called 'item' with Any Type.
a!dashboardLayout(
firstColumnContents: {
a!textField(
label: "Test",
value: rule!CASE_APP_randomItemFromArray(item: ri!item)
)
}
)
To Test it out, let us assume you have employee cdt and DS with some fields in employee cdt like id, fname and lname. Also assume that you have a query rules like getEmployeeById(id) which returns the specific employee based on id. I am assuming you have atleast 5 records of employee in DS.
Now Test this rule in interface designer. While gving the input in interface designer, give the input like this: {getEmployeeByid(1), getEmployeeByid(2), getEmployeeByid(3)}
Each time you execute/test this rule, you will get a different output. In short, the above rule just takes an array of "items", where items can be any type of CDT.(might be something other than employee, this is just an example.). This rule then selects a random 'item' i.e random CDT from the input array and returns it.
Now, the same rule definition in screenshot can be rewritten as :
=ri!item[rule!CASE_APP_random(length(ri!item))] instead of
=item[rule!CASE_APP_random(length(ri!item))]
It does not change the meaning. It just returns a random cdt from the passed array of cdts.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Children
No Data