Get User or Group Name

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 

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    = 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 said you can first check if username taken or group exist. above code is one of the example.

Reply
  • 0
    Certified Lead Developer

    = 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 said you can first check if username taken or group exist. above code is one of the example.

Children