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
10 replies
Subscribers
9 subscribers
Views
9517 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
General
Is there any function available to check if variable value is "User" or "group"?
Amir Hanif
Certified Lead Developer
over 8 years ago
Hi,
I have a variable "assignee" of "User or Group" type. I want to know if user enter "User" or "group" as an input for this variable. Is there any function available to check if variable value is "User" or "group"?
OriginalPostID-271256
Discussion posts and replies are publicly visible
Top Replies
Durgesh
over 8 years ago
+1
A Score Level 2
AFAIK there is no in-built function to verify weather it is a user or group. I think you can make a use of typeof() function to check this. This function return integer value for the type. Suppose, if…
0
Durgesh
A Score Level 2
over 8 years ago
AFAIK there is no in-built function to verify weather it is a user or group.
I think you can make a use of typeof() function to check this. This function return integer value for the type.
Suppose,
if variable is of type "User" then it will return = 4
If variable is of type "Group" then it will return = 5
If variable is of type "User or Group" then it will return = 27
Let us know if that works for you.
Cancel
Vote Up
+1
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Amir Hanif
Certified Lead Developer
over 8 years ago
Typeof(ri!assignee) always return 27 because variable type is "User or Group".
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Durgesh
A Score Level 2
over 8 years ago
I have found one alternative to your ask - create an expression rule and pass one input parameter of type (User or Group). Write below code inside expression rule, verify it.
with(
local!castValue: cast(3, ri!input),
find("[", local!castValue, 0) /* 1 means Group, 0 means User*/
)
Let me know if that works.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Durgesh
A Score Level 2
over 8 years ago
Also, remember - check for NULL value of the input parameter before you cast it (handle NULL check). Also, you can return TRUE or FALSE based on the result.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Amir Hanif
Certified Lead Developer
over 8 years ago
Thanks durgeshk! It is working but I also found a function to resolve the issue. runtimetypeof function returns runtime type of variable.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
nathan.schmitz
Certified Associate Developer
over 8 years ago
The runtimetypeof has worked for me in the past.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
chetany
A Score Level 1
over 8 years ago
runtimetypeof() is the most appropriate function for this use case. note that an appian datatype like 'user or group' is a 'compound/union datatype' since the value can be either of the type of group or user.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Rama Thummala
Certified Lead Developer
over 8 years ago
@amirh504,
Below code snippet would be helpful.
Here the input ri!userOrGroup is User or Group type List
"Users - " & touser(
ri!userOrGroup
) & ", Groups - " & togroup(
ri!userOrGroup
)
Please add the required conditions or logic based on your requirement.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
snehalh
A Score Level 1
over 6 years ago
We had same requirement for a project, and I tried some solutions given here but they didn't work for me.
So here is my solution, see if it helps you:
if(find("Group",tostring(try(
togroup(ri!input),touser(ri!input))),1),"Group",
isusernametaken(tostring(ri!input)),"user","notUserorGroup")
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
chandu
A Score Level 2
over 6 years ago
in reply to
snehalh
Hi Sneha,
Its always good to avoid using internal functions like try(), these internal functions evaluations might be changed from one release to other release.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel