Andrew – I work with Brett who responded above and she can’t figure out where I am screwing up. This WAS working a few days ago and I don’t know what kinked it up.
I have a people picker that is only entered on the NewForm and I want to pull out LastName & FirstName into their own fields. I cannot get LastName FirstName fields to display in the DispForm. They display fine on the EditForm.
Do I need code on all three forms or just one?
This is the code I am using on the NewForm and EditForm
function PopulateLastFirst ()
{
//Pull in Last Name and First Name from Employee field.
$.each(spjs.utility.getFieldValue({"fin":"Employee","key":"loginName"}),function(i,login){
var ppData = spjs.utility.userInfo(login);
console.log(ppData);
// User profile is not available in SP Foundation
var userProfile = spjs.utility.userProfile(login);
console.log(userProfile);
setFieldValue("Last_x0020_Name",userProfile.LastName);
setFieldValue("First_x0020_Name",userProfile.FirstName);
});
}
This is the code I have on the DispForm
function PopulateLastFirst ()
{
$.each(spjs.dffs.beforeProperties["Employee"],function(i,userId){
var ppData = spjs.utility.userInfo(userId);
console.log(ppData);
// User profile is not available in SP Foundation
var userProfile = spjs.utility.userProfile(ppData.Name);
console.log(userProfile);
setFieldValue("Last_x0020_Name",userProfile.LastName);
setFieldValue("First_x0020_Name",userProfile.FirstName);
});
}
I even tried this on advice from Brett… on the DispForm
function PopulateLastFirst ()
{
$.each(spjs.dffs.beforeProperties["Employee"],function(i,userId){
var ppData = spjs.utility.userInfo(userId);
console.log(ppData);
// User profile is not available in SP Foundation
var userProfile = spjs.utility.userProfile(ppData.Name);
console.log(userProfile);
});
}
Any help you could give would be much appreciated.