Using REST and JavaScript to write Multiple People Picker values to ListItem people picker column

Posted on 2016-10-26
Last Modified: 2016-11-27
I am searching for an example of writing a listitem from a people picker control to a people column of the list.
Question by:Howard Bash
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 82

Expert Comment

ID: 41893777
do you still need help on this one?
LVL 82

Expert Comment

ID: 41893813
could you please do a screen copy of your page or just create a funny photoshop schema, I currenlty don't understand where you want to go.

Author Comment

by:Howard Bash
ID: 41897559
I have figured out/found the techniques for this. Thanks.
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

LVL 82

Expert Comment

ID: 41897574
ok, please close the question. if possible after posting your solution and accept it as answer.

Accepted Solution

Howard Bash earned 0 total points
ID: 41897586
// Convert People Picker String to JSON Array
function UserInfoFromPP(ppID) {
	var sObj = $(ppID).val();
	var jObj = null;
	if (sObj.length>0)
		jObj = JSON.parse(sObj);
	return (jObj);

//  You need to construct a string of the form '{"results":["id1", "id2"]}'
function BuildPeepsString() {
	var jObj = UserInfoFromPP('#peoplePickerDiv_TopSpan_HiddenInput');
	var acc = '{"results":[';
	var ptr = 0;
	var id = "";
	if (jObj) {
		var len = jObj.length;
		for (ptr=0; ptr<len-1; ptr++) {
			id = GetUserProfileAttribute(jObj[ptr].Key, 'ID');
			acc = acc + '"' + id + '"' + ",";						
		id = GetUserProfileAttribute(jObj[len-1].Key, 'ID');
		acc = acc + '"' + id + '"' ;						
		acc = acc + ']}';

	return (acc);

function HelpAddPostWithParameters(pp, title, body) {
	//var peeps = '{"results":["9", "21"]}';
	var jsonObject = JSON.parse(pp);
	AddPostWithParameters('Posts', title, body, jsonObject);

function AddPostWithParameters(plistName, pTitle, pBody, pPeopleObject) {
	var itemProperties = {"Title":pTitle,"Body": pBody, "PublishedDate":new Date().toISOString(), 	
	"PeopleRecognizedId":  pPeopleObject 
	//create item
		  console.log('Post ' + entity.Title + ' has been added');

//.... on a submit added the following fragment:
               var comments = $('#txtComments').val();
		var peepsString = "";
		peepsString = BuildPeepsString();  
		var demonstratedValue = $('#hiddenDemonstratedValue').val();
		if (peepsString){		
			HelpAddPostWithParameters(peepsString, demonstratedValue, comments);

Open in new window

LVL 16

Expert Comment

by:Kyle Santos
ID: 41897821

Thank you for posting your solution and closing your question.

Author Closing Comment

by:Howard Bash
ID: 41902942
It solved the problem.

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question