Skip to main content
Known Participant
May 10, 2021
Solved

How to get username on the basis of first name ?

  • May 10, 2021
  • 20 replies
  • 0 views

I want to retrieve user name on the basis of first name . How can I achieve this ?

    Best answer by bryant.st39

    a!localVariables(
    local!userList: getdistinctusers(cons!GLB_DEVELOPERS_GROUP),

    a!dropdownField(
    label: "Dropdown",
    labelPosition: "ABOVE",
    placeholder: "--- Select a Value ---",
    choiceLabels: a!forEach(
    local!userList,
    user(fv!item, "firstName") & " " & user(fv!item, "lastName")
    ),

    choiceValues: local!userList,
    saveInto: {},
    searchDisplay: "AUTO",
    validations: {}
    )
    )

    20 replies

    sowrabhar0001
    Participating Frequently
    May 10, 2021

    Hi Aman, There could be multiple people with the same first name, so the search would return multiple users, which wouldnt be the right thing to do. What is the usecase? You could use a user picker and people could type in to get the name of the user from the name

    amang0002Author
    Known Participant
    May 10, 2021

    I have a drop down field from where I get user first and last name. From these 2 fields I need to retrieve username. How can I retrieve username ?

    sowrabhar0001
    Participating Frequently
    May 10, 2021

    Again, is it possible to reconsider the approach of displaying users in a dropdown, to displaying them in a user picker. The problem being, in Appian its possible to have multiple users with the same first name and last name combo, which means your search would result in multiple usernames, is that fine?

    Participating Frequently
    May 10, 2021

    How are you getting the list of to populate the drop down?  There is a plugin that can be used to search users by properties, but if more than one user is returned with the same first name and last name, that would be an issue because you cannot ensure you are selecting the correct user.  

    This plugin, https://community.appian.com/b/appmarket/posts/personalization-utilities, will allow you to search users by various fields.

    usersearch(
      {"firstName"},
      {0},
      {"Larry"}
    )

    sowrabhar0001
    Participating Frequently
    May 10, 2021

    Agree