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
+3
person also asked this
people also asked this
Replies
14 replies
Subscribers
10 subscribers
Views
20219 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
This is a question about the behavior of fn!index() function. The syntax is fn!i
chetany
A Score Level 1
over 8 years ago
This is a question about the behavior of fn!index() function. The syntax is fn!index(array, indices, defaultValToReturn).
The defaultValToReturn is of AnyType. Documentation mentions that default value should be of the same type as array elements. I find the behavior of index function strange in the below case:
fn!index( {4,5,6}, 1000, {}) -- As expected it returns a empty list i.e List of Variant since array size is less than 1000.
Now try, fn!index( {4,5,6}, {1000}, {} ) - This returns 4 - the first element in the array. I did not expect this result.
Now try, fn!index( {4,5,6}, {1000}, null ) - This returns nothing as expected.
Why does it behave in such manner for case 2? It always returns the first element whenever a multiple indices are provided and the default value is also an empty list.
Also try: fn!index({4,5,6}, {2,1000}, {}) - this returns 5,4. The 4 is the first element of the array.
I...
OriginalPostID-184786
OriginalPostID-184786
Discussion posts and replies are publicly visible
Parents
0
kumaraveln
over 8 years ago
When you use null / null() / 0 as default value it will work as expected .. But using {} is not correct as far as i have seen .. normally if you want to return a null value you should always use null() <whatever can be the datatype .. text, cdt, or anything> .. {} will actually initialize the variable on the left in some case (not in all case) ..
But in this case, even using {} should not return first value .. May be a bug .. But always use null() for nullifing any data type object so that you have to check only isnull() later but if you use {} or "" you may also need to check length()=0 or len()=0 ..
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Reply
0
kumaraveln
over 8 years ago
When you use null / null() / 0 as default value it will work as expected .. But using {} is not correct as far as i have seen .. normally if you want to return a null value you should always use null() <whatever can be the datatype .. text, cdt, or anything> .. {} will actually initialize the variable on the left in some case (not in all case) ..
But in this case, even using {} should not return first value .. May be a bug .. But always use null() for nullifing any data type object so that you have to check only isnull() later but if you use {} or "" you may also need to check length()=0 or len()=0 ..
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Children
No Data