I'm using a function to grab the id from the url of the record and fetching numerous field values successfully. It seems to work fine for all fields except for people pickers. When I display the fields in an alert for testing purposes I am seeing the following:
"Joe's Bait Shop [object object]".
I am using js to clone records and usually grab values from the form using the id of the field, however, grabbing values from pp fields has got me stumped.
I've tried using SPServices
$().SPServices.SPFindPeoplePicker
and get the same result. Below are the two functions I'm using:
// Submit clone record
function clientContxt(rID) {
clientContext= new SP.ClientContext();
targetList = clientContext.get_web().get_lists().getByTitle('TG Hosted');
targetListItem = targetList.getItemById(rID);
clientContext.load(targetListItem, 'Customer_x0020_Company_x0020_Nam', 'Account_x0020_Manager');
clientContext.executeQueryAsync(onLoadSucceeded, onQueryFailed);
}
// Load list item fields
function onLoadSucceeded()
{
custName = targetListItem.get_item('Customer_x0020_Company_x0020_Nam');
accountMan = targetListItem.get_item('Account_x0020_Manager');
alert(custName+" "+accountMan);
}
I've searched this forum and google for answers and can't seem to connect all the dots. Thank you.
EDIT
Here is the code for SPServices
that I tried. When I use this I get an alert that is empty and my debugger comes up with this error. I am using the display form.
Object doesn't support property or method 'addEventListener'
var aMan = $().SPFindPeoplePicker({peoplePickerDisplayName: "Account Manager"});
var vaMan = aMan.currentValue;
alert(vaMan);
Account Manager
from the field in the display form, or by fetching the item using the ID pulled from the URL? Or does it not matter to you which way it's done as long as you get the value?