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:
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.