Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a function in presave that takes the user name in the people picker available on the form and do some business logic. After completion of script the actual save function is called.

The issue is that if the value entered in people picker is not resolved (even if the value is valid name) then the value is not received correctly in the presave function.

I have tried to call the click of people picker resolution but since its asynchronous function i cannot get the entire value ie. domain/alias before my further code starts executing.

Any idea on how to achieve this.

share|improve this question
1  
have u tried like this.. var valueOfPeloplePicker = $("[id$='upLevelDiv']").text(); –  Hitesh Chandegara Dec 28 '12 at 9:38

3 Answers 3

You could try using the SPServices library to get a handle on the field and initiate a name resolution through JavaScript. In specific, take a look at the SPFindPeoplePicker function:

$().SPServices.SPFindPeoplePicker

http://spservices.codeplex.com/wikipage?title=%24%28%29.SPServices.SPFindPeoplePicker

Take a look at the checkNames section:

checkNames

This is a reference to the checkNames img tag in the People Picker. It’s used by the function to initiate resolution of a Person or Group value by firing the click event on it. Once you have this reference, you can do the same.

You could probably also figure out how to do this on your own without the use of SPServices. Just get a handle on the image and initiate a click().

share|improve this answer
    
I just re-read your question and realized you tried essentially doing this. Have you tried initiating the resolution onblur, when the person leaves the field? –  JesseC Dec 28 '12 at 16:18
    
but if the mouse control is on the people picker and then directly "Save" is clicked then onblur will not fire. So it won't be of any help to me. –  Monica Jagani Dec 31 '12 at 5:05
    
click() event of image is also asynchronous so i cannot control my code after that –  Monica Jagani Dec 31 '12 at 5:07

In order to check (on the client side) if the value entered in people picker is resolved the following function could be used

//Determines If People Picker value is resolved (using jQuery)
function IsPeoplePickerValueResolved() { 
   var eEntityData = $("div[id='divEntityData']");
   if(eEntityData.length > 0 ) {
       var isResolved = eEntityData.attr("isresolved");
       return (isResolved == "True"); 
   }    
   return false;
}

Gist link

Usage

function PreSaveAction() { 
   var isResolvedUser = IsPeoplePickerValueResolved();
   //...   
   return true;
}

For example,

enter image description here

returns false


enter image description here

returns true

share|improve this answer

$().SPServices.SPFindPeoplePicker does not work. The method is not supported on a person/group field.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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