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
6 replies
Subscribers
8 subscribers
Views
2485 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
I have observed unexpected behavior for isusernametaken function. When we pass a
chetany
A Score Level 1
over 9 years ago
I have observed unexpected behavior for isusernametaken function. When we pass an empty string to it, it returns true.
As per my understanding this should not be the case. isusernametaken should return true for only the users which exist (activated/deactivated) in the system. This was observed on Appian 7.11
fn!isusernametaken("") - true
OriginalPostID-205763
OriginalPostID-205763
Discussion posts and replies are publicly visible
0
jamesw644
over 9 years ago
I just confirmed this on my 7.11 site as well. Hopefully this gets picked up for the next hotfix.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 9 years ago
I think this will not change as the behaviour of some older Appian functions is not consistent in some edge cases but running systems depend on this. Just try "=not(null)" and "=if(null, true, false)". So my suggestion is to wrap isusernametaken() this in an expression which does some additional checks.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Shyam Bommakanti
Certified Lead Developer
over 9 years ago
fn! doesn't have side effects, meaning if should always return expected value. isusernametaken() is a bool, and think of passing null as divided by 0. What should happen, when your only possible return value is a number?
One of the purposes is you should be able to create users based on output of this function, if it returns false for null creating the user fails.
As @stefanh791 mentioned, use a wrapper to check for null.
For more context, from Appian common objects rule!APN_displayUser, it checks for null ahead, as I said earlier, fn! functions should have no side effects, so check for null and handle accordingly:
if(isnull(ri!user), "",
if(isusernametaken(ri!user),
user(ri!user, "firstName") & " " & user(ri!user, "lastName"),
tostring(ri!user)
))
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
chetany
A Score Level 1
over 9 years ago
@Shyamb, it is not about fn! , which is simply an optional domain prefix for Appian functions.
I meant that the function isusernametaken returns true even if we pass an empty string. I think it should return false or it should give an error when empty string is passed.
As suggested by Stefan, we can use isnull before passing it to the function.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Nick Vigilante
Appian Employee
over 9 years ago
The behavior is unexpected. It should not return true when passed a null string. I have logged this to our product team for further investigation. The previous suggestions to work around this are great suggestions, so for the time being, I would consider following those.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
chetany
A Score Level 1
over 9 years ago
Thank you Nick.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel