Skip to main content
gangadharr0001
July 22, 2021
Question

Get User or Group Name

  • July 22, 2021
  • 3 replies
  • 0 views

if(
  rule!APN_IsBlank(ri!userOrGroup),
  "",
  if(
    runtimetypeof(topeople(ri!userOrGroup)) = 'type!{http://www.appian.com/ae/types/2009}User',
    user(touser(ri!userOrGroup), "firstName") & " " & user(touser(ri!userOrGroup), "lastName"),
    if(
      runtimetypeof(topeople(ri!userOrGroup)) = 'type!{http://www.appian.com/ae/types/2009}Group',
      group(togroup(ri!userOrGroup), "groupName"),
      ""
    )
  )
)

Hello All,

Please find the above code ( rule it is to get user or group name )

when you enter a user name it's showing it is  user and when you Test with a group name it's giving me an error 

Please look at the code is there any mistake 

Thanks in advance 

3 replies

malathik
July 22, 2021

Hi,

Can you share the error that you are getting? Also, assuming you are using user or group type rule input. 

If you do not know the type then you can make use of username taken and group existing function to just ensure valid input data.

gayathris111098
July 22, 2021

= if(
runtimetypeof(
ri!userOrGroup
) = tointeger(
'type!{http://www.appian.com/ae/types/2009}Group'
),
if(
doesgroupexist(
togroup(
ri!userOrGroup
)
),
group(
togroup(
ri!userOrGroup
),
"groupName"
),
"N/A"
),
user(touser(ri!userOrGroup), "firstName") & " " & user(touser(ri!userOrGroup), "lastName"),
)


Please share the error you are facing?

Like [mention:f05860571cad4e6b91913b55d05a252b:e9ed411860ed4f2ba0265705b8793d05] said you can first check if username taken or group exist. above code is one of the example.