Get FullName from UserName with delimitation
Hello,
I have a User List activity with Multiple Selection enabled and the value property is the UserName.
After submitting the form, the value for this field is Username1;Username2;Username3 and so on.
The problem is that I need to get also the FullName. I tried to use the "Get User Information" activity but it does not work with ";". I can't simply change the Value property to Fullname because I also need the UserName.
Is there any way to achieve what I need?
Thank you!
-
Official comment
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
Please sign in to leave a comment.
Comments
1 comment