• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 64
  • Last Modified:

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

I am searching for an example of writing a listitem from a people picker control to a people column of the list.
Howard Bash
Howard Bash
  • 3
  • 3
1 Solution
do you still need help on this one?
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.
Howard BashSenior Software EngineerAuthor Commented:
I have figured out/found the techniques for this. Thanks.
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

ok, please close the question. if possible after posting your solution and accept it as answer.
Howard BashSenior Software EngineerAuthor Commented:
// 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

Kyle SantosCustomer RelationsCommented:

Thank you for posting your solution and closing your question.
Howard BashSenior Software EngineerAuthor Commented:
It solved the problem.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now