1

I have multi value Person or Group field and a Multi text of Line field in my SHarePoint online site. On NewForm I want to fetch all the users' EMail and save it to Multi text field separated by semicolon using javascript/jquery.

Can someone please help me to achieve this ?

  • Is there any update? Does it work? – JoannaW_MSFT Mar 20 at 11:25
1

Try using the following scripts in the NewForm.aspx.

<script type="text/javascript" src="https://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
    $(function () { 
        SP.SOD.executeFunc('clientpeoplepicker.js', 'SPClientPeoplePicker', function() {
            // people picker field name
            var fieldName = "people";
            // multiple line text field name
            var textName = "emails";
            var PeoplePicker = $("div[title='" + fieldName + "']");
            var multipleText = $("textarea[title='" + textName + "']");
            var pickerId =PeoplePicker[0].id;
            // when the people picker value is changed
            SPClientPeoplePicker.SPClientPeoplePickerDict[pickerId].OnValueChangedClientScript=function (peoplePickerId, selectedUsersInfo) {
                console.log(peoplePickerId+";"+selectedUsersInfo);
                var emails ="";
                if(selectedUsersInfo.length > 0){
                    for (var i=0; i< selectedUsersInfo.length; i++){
                        // get email for each person
                        var email = selectedUsersInfo[i].EntityData.Email;                      
                        emails += email+ ";\n";
                    }   
                }
                multipleText.val(emails);
            };          

        });     
    });
</script>

Note: in this demo, the "emails" multiple lines of text field is plain text field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.