Get FullName from UserName with delimitation

Comments

1 comment

  • Official comment
    Avatar
    Varun Agasthya

    Rafael,

    As the UserList is of name-value type, it would not be possible to show or store both UserName and FullName. However, if FullName and UserName is selected as Name and Value respectively in the Userlist control configuration (as shown in the screenshot), we can get the selected user's UserName and FullName by making use of a small JavaScript snippet as below:

    function getSelectedUsers() {

        let userlist = document.getElementById('UserList1'); //UserList1 is the intername of the Userlist control

        let selectedUsers = userlist.selectedOptions; //List of selected Users

        const selectedUsersList = [];

        selectedUsers.forEach(function (user) {

            selectedUsersList.push({

                Username: user.value,

                Fullname: user.text

            }); //user.value gives the username and user.text gives the fullname. (These can be stored in variables and used according to the user requirement)

        });

        console.log(selectedUsersList);

    }

     

    Thanks

    Comment actions Permalink

Please sign in to leave a comment.