Skip Ribbon Commands
Skip to main content

:

> Posts > Yay! Did SharePoint 2013 finally decide to be consistent with Lookups?
August 07
Yay! Did SharePoint 2013 finally decide to be consistent with Lookups?

So, all of us client side developers were having a heck of a time dealing with setting and getting the value of lookup fields in SharePoint because the field changed from a “select” to an “input” when a lookup list had more than 20 items.  This blog should refresh your memory on that:

Setting SharePoint Lookup Lists w/ jQuery (+/- 20 items)

Luckily it looks like Microsoft decided to be consistent in SharePoint 2013 and it seems to always use a select (at least it’s still a select after 57 entries). So, if you want to read the value of a lookup in SharePoint 2013 you just need one line:

$("select[title='<field display name>']").val();  
And to set a lookup using jQuery we just need one line:
$("select[title='<field display name>']").val("<ID to set>");  
So, at least in one aspect our life got a little easier. Although I will caveat this:
  • SharePoint 2013 is still in “Preview” so they could change the functionality (although I’d doubt it at this point)
  • A lookup may still change to an input at some other magical number?
Just hedging my bets people… but so far I’m really digging SharePoint 2013. 

Comments

There are no comments for this post.

SharePoint Architect, Developer, Blogger, Speaker, Author, and general pain in the butt.
 
Thoughts, views, and opinions expressed in this blog are solely my own.
 
Remember, the Impossible just takes longer.
​​​​
 

 Blogs you should be reading