Concatenate multiple person fields in one
Hello,
I'm trying to concatenate 3 persons fields into one field.
Every solution that I tried failed:
[[PAD]] + [[RPAD]] + [[ServiceDirector]]
[[PAD]] ; [[RPAD]] ; [[ServiceDirector]]
[[PAD]] + ";" + [[RPAD]] + ";" + [[ServiceDirector]]
[[PAD]] & [[RPAD]] & [[ServiceDirector]]
...
I've added these possibilities in the 'Calculated' expression builder. The field that has this calculation is enabled for multiple persons.
Is this possible to do?
Some background info: The reason why I want to do this is because not all fields are filled in in every situation. I just want a field that concatenates all 'Owners' no matter which situation that the user has picked. The above fields (PAD, RPAD & ServiceDirector) will be placed on not visible.
Thanks for the reply.
Kr,
Jan
-
Hello Jan Vanderstappen,
You need to select Template expression type from dropdown.
The expression should look like that :
[[PAD]][[RPAD]][[ServiceDirector]]Regards
Rosario Matos
0 -
Hello Rosario,
Thank you for your answer. Unfortunatelly this doesn't work for me:
The names are glued together and are being resolved as one name.
This is my formula:
And this is my column configuration:
Am I missing something?
0 -
Hello Jan Vanderstappen
I prepared calculated value expression code for you.
Please insert this code as Calculated Expression for Contract owner multi user fieldvar MULTI_USER_FIELD_NAME = 'Contract owner';
var UserField1 = [[PAD]];
var UserField2 = [[RPAD]];
var UserField3 = [[ServiceDirector]];
var updateMultiUserFied = function(){
var multiUserField = jQuery(".ard-formwebpart [title='"+MULTI_USER_FIELD_NAME+"']").find("input[id$='ClientPeoplePicker_EditorInput']").get(0);
if(multiUserField){
var loginNames = '';
if(UserField1 && UserField1.Key) loginNames = loginNames + UserField1.Key + ";" ;
if(UserField2 && UserField2.Key) loginNames = loginNames + UserField2.Key + ";" ;
if(UserField3 && UserField3.Key) loginNames = loginNames + UserField3.Key + ";" ;
var peoplepicker = SPClientPeoplePicker.PickerObjectFromSubElement(multiUserField);
peoplepicker.AddUserKeys(loginNames);
}
}
setTimeout(updateMultiUserFied,200);
return ;Kind Regards
Andriy Berezovsky0 -
Thanks Andrew!
Your code works!
I do feel that this is a lot of code for something small like concatenate people fields. Do you think that a solution like Rosariu mentioned will be available once?
Thanks!
0 -
Hello Andrew,
It seemed to work on the first time but after some testing some bugs occured.
First of all, when I change a value in the form, the code ran 3 times which occurred in users that where added 3 times.
For example:
Pad User, RPAD User, PAD User, RPAD User, PAD User, RPAD User.
I've been able to work around that by deleting all values in the people picker prior of adding them:
var peoplepicker = SPClientPeoplePicker.PickerObjectFromSubElement(multiUserField);
//Remove all existing values
var allUsers = peoplepicker.GetAllUserInfo();
allUsers.forEach(function (index) {
peoplepicker.DeleteProcessedUser(allUsers[index]);
});
//Add new values
peoplepicker.AddUserKeys(loginNames);The other bug that I noticed is that the code doesn't run when a value of one of the first peoplepickers is emptied. The contract owner field does not get updated. I haven't found a solution for this yet. Do you have something in mind?
I've tried adding a 'Contract owner = ""' statement in one of the source fields but this gives me an infinite loop.
Thanks for the help!
0 -
Support team told me that you overcome this issue, can you share with the Community which steps did you took it.
Thanks
Rosario Matos
0 -
Hello Rosario,
The three original people fields are automatically calculated when a certain value is chosen from several dropdowns. I've just made sure that these dropdowns where required and being emptied on the right time.
By doing that I'm always requiring a user interaction which then calculates the people fields (and thus overwriting the last calculated values).
It's kind off hard to explain but this work around works in my situation.
Either way: It would be nice if you could just concatenate people fields by using PeopleField1 + PeopleField2 or something like that :-)
0 -
0
-
0
Please sign in to leave a comment.
Comments
9 comments