JavaScript SharePoint People Picker

Yes.. JavaScript SharePoint People Picker… try saying that 3 times fast.

Anyway, I needed one for a form I was developing. It had to be client side, and it needed to work with SharePoint.

In SharePoint 2013, there’s already support for this: http://msdn.microsoft.com/en-us/library/jj713593.aspx

But I need something for SharePoint 2010. I found several articles on manipulating the data in the people picker, but very little on creating a people picker. I continued to google, and my googling bore fruit:

Tanmay Shahane has a neat little bit of code that uses the EntityEditor.js to create a people picker – obviously you should be including jQuery into your page for Tanmay’s script to work. The complete post is here: http://community.zevenseas.com/Blogs/Tanmay/Lists/Posts/Post.aspx?ID=7

But if the link is broken or something, Tanmay’s code as follows:

function EntityEditorHandleCheckNameResult(result, ctx) {
    ULSGjk: ;
    EntityEditorClearWaitCursor(ctx);
    EntityEditorCallback(result, ctx);
    //login name
    var loginName = $(“span.ms-entity-resolved”).attr(“title”);
    //display name
    var displayName = $(“span.ms-entity-resolved div:first-child”).attr(“displaytext”);
//Your custom code can go here for populating rest of the fields in the form calling user profile through client object model
}

Paul Tavares has some interesting widgets for People picking and Uploading that look promising, but I have yet to try them out:

http://paultavares.wordpress.com/2012/04/28/sharepoint-ui-widgets-upload-and-pickusers/

Multiple Lists and IE9.. it continues

So when last we left, I was frantically tearing what’s left of my hair out, attempting to debug what was going on with JavaScript and Flash and Internet Explorer to make them hate each other.
As It turns out, in my scripts, I hide my flash object when it is not being directly accessed by the user. (It’s mimicking an attachment popup, so why would I have it sitting in the middle of the page unless the user wanted to attach something anyway?) I was doing this using “display: none”.
Bad, bad, bad coder!
There is a browser quirk, where if the Flash object is not rendered (e.g. “display: block”), the browser doesn’t recognize the object.
I replace the “display: none” with the “left: -5000px” trick, and viola! Flash and JavaScript and IE are talking and everyone is happy again.

SharePoint Calendar Colors with JavaScript

Yes, there is a “codeless” way to do this using views and calendars, but you may want to use the JavaScript method to get more than just the standard colors that ship with SharePoint 2010.

How to add color coded categories to your calendars with JavaScript:

Caveats:

This solution uses Calculated Fields to display colors related to a particular category. The Category column MUST be a choice column – a lookup column will not work as look-up columns are NOT allowed in Calculated Field Column equations.

You must be able to add a Content Editor Web Part to the pages where the calendar will be viewed.

Part 1: Setting up the JavaScript:

  1. Copy the following script into a text file: