Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Suggested Answer
+2
person also asked this
people also asked this
Replies
8 replies
Answers
3 answers
Subscribers
10 subscribers
Views
17646 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
Is there a case statement /function in Appian . or an if ...else if in rules exp
Dhiraj Kumar
over 8 years ago
Is there a case statement /function in Appian . or an if ...else if in rules expressions . Coding in terms of if , if ... is time consuming and code readability is bad .
OriginalPostID-219960
OriginalPostID-219960
Discussion posts and replies are publicly visible
Parents
+1
chetany
A Score Level 1
over 8 years ago
I would suggest a combination of fn!choose and fn!displayvalue to simulate a "switch" case in Appian. fn!choose is like switch case - but with one caveat - the "key" should be a number - it does not allow text values or float values. So, you can use fn!displayvalue with fn!choose when the value which decides which branch to takes is not a number.
Example Snippet:
load(
/*local!statusCode will be 1 or 2 or -1
1 - Approved
2 - Rejected
-1 - Some invalid value*/
local!statusCode: fn!displayvalue(
ri!status,
{"Approved", "Rejected"},
{1,2},
-1
),
fn!choose(
local!statusCode,
{
/*code for choice1 */
},
{
/*code for choice2 */
}
)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Reject Answer
Cancel
Reply
+1
chetany
A Score Level 1
over 8 years ago
I would suggest a combination of fn!choose and fn!displayvalue to simulate a "switch" case in Appian. fn!choose is like switch case - but with one caveat - the "key" should be a number - it does not allow text values or float values. So, you can use fn!displayvalue with fn!choose when the value which decides which branch to takes is not a number.
Example Snippet:
load(
/*local!statusCode will be 1 or 2 or -1
1 - Approved
2 - Rejected
-1 - Some invalid value*/
local!statusCode: fn!displayvalue(
ri!status,
{"Approved", "Rejected"},
{1,2},
-1
),
fn!choose(
local!statusCode,
{
/*code for choice1 */
},
{
/*code for choice2 */
}
)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Reject Answer
Cancel
Children
No Data