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
11 replies
Subscribers
8 subscribers
Views
4699 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
Hi, Im trying to fetch different constant values based on different c
divyav
over 9 years ago
Hi,
Im trying to fetch different constant values based on different conditions for choice labels and choice values of "Dropdown field", Each constant has 2 values, but it is returning only single value when I use "Like" conditions. If I use "=", all values of constants are returning. Please see the code below
ChoiceLabels:
if(
like(ri!cdtxyz.tfield,"*New*"),
cons!NEW_LABELS,
if(
like(ri!cdtxyz.tfield,"*Renewal*"),
cons!RENEWAL_LABELS,
if(
like(ri!cdtxyz.tfield,"*Modification*"),
cons!MODIFY_LABELS,
cons!TERMINATE_LABELS_))),
Similarly for Choice values also.
Please suggest any solution to return all values of constants, when like condition is matching
OriginalPostID-208632
OriginalPostID-208632
Discussion posts and replies are publicly visible
0
Stefan Helzle
A Score Level 3
over 9 years ago
I am not sure that the "like" is the problem. Have you double checked that your constants are defined as multiple?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 9 years ago
Could it be that ri!cdtxyz.tfield is multiple with just a single item. My small test shows this behaviour:
if(
like({"New"},"*New*"),
{"a", "b"},
{"c", "d"}
)
It returns just "a".
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
divyav
over 9 years ago
yes they are multiple.. they are working fine when I check for exact match using "="
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Vinay Kumar Rai
over 9 years ago
Hi,
Your condition may return list.
use : or( like(ri!cdtxyz.tfield,"*New*"))
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
divyav
over 9 years ago
not sure.. In my scenario, cdt is single
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 9 years ago
Is ri!cdtxyz defined as ANY type? Add a ready only text field just showing "ri!cdtxyz.tfield". Then use "typename(runtimetypeof(ri!cdtxyz.tfield))". This will show you exactly how your data is structured.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sagarl511
A Score Level 2
over 9 years ago
@stefanh791 - I went through your example - if(
like({"New"},"*New*"),
{"a", "b"},
{"c", "d"}
)
Isn't it unexpected where output is "a". I tried it and it should return {a,b}. As if() evaluates boolean and also - like({"New"},"*New*") returns true it should return {a,b}. Do you have any idea why is it behaving in this way?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sagarl511
A Score Level 2
over 9 years ago
@divyav - Can you try this - like(tostring(index(ri!cdtxyz,"tfield","")),"*New*")
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 9 years ago
This is the way Appian handles data. Most of the times it works like you expect it. But sometimes not. So in this case my explanation is: like() on a multiple returns a list of bools.
=typename(runtimetypeof(like({"New"},"*New*"))) -> List of Boolean
Now if() tries to evaluate a list of bools. Which works fine for:
=if(
{true,false,true},
"a",
"b"
)
But as you return lists of string for each case these creates a list of lists which is somehow flattened. This is where it breaks.
So try to put the like() inside an or() or make sure that your ri variable is no multiple.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sagarl511
A Score Level 2
over 9 years ago
@stefanh - If I execute - if(
{true,false,true},
"a",
"b"
)
Output - a; b; a.
if() function must have only boolean returning function which can never be a list or multiple.
like({"New"},"*New*") - returns list of boolean and hence it behaves wierdly.
Also like({"New","Newfds"},"*New*") - returns {true,true}
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
>