Error: Value does not fall within the expected range

1 Comment

Last week i was working with a list where i have more than 10 lookup fields. By Default sharepoint does not allow more than 8 lookup column to be shown in a view but you can have there columns in the list if not showing in a single view.

In my code, i was reading the 10 people picker value based on a condition using SPQUERY and then copying it to another list.
While accessing 9th lookup column, i got the error “Value does not fall within the expected range”. After investigating the problem I had found that returned list object contains only 8 lookup fields.

You will face this issue for all fields above threshhold value.

Solution:

Earlier I was using

SPListItemCollection coll = configList.GetItems(query);
if (coll.Count > 0)
{
SPListItem confiitem = coll[0];
}

Instead of using SPQUERY returned SPListitem, i used

SPListItemCollection coll = configList.GetItems(query);
if (coll.Count > 0)
{
SPListItem confiitem1 = coll[0];
SPListItem confiitem = configList.GetItemById(confiitem1.ID);
}

Strange but item returned through GetItemById allows you to access lookup column (i.e. People picker column) above threshhold value as well

Hope it will help you….

Technology Consulting

Leave a comment

A batch of Engineering graduates joined my company recently and I got opportunity to share my experiences in Technology consulting with them. It was fun.

The Slides is i used for the discussion.
technology-consulting

SharePoint current Site Collection or site URL in JavaScript

1 Comment

SharePoint current Site Collection or site URL in JavaScript

In Sandbox Solutions or Office 365, many times you need to get the URL of the current site to use in JavaScript.

With the ECMAScript Client Object Model, there are multiple ways to access the current site URL like SP.Site.get_url() for the Root site URL or SP.Web.get_serverRelativeUrl() for the relative url of the current site.

But for plain JavaScript code, there is an easier way to get the URL by using the OOB JavaScript variable L_Menu_BaseUrl which stores the URL of the current Web or the Subsite.

There are some more OOB Javascript variables which can be useful. 

L_Menu_LCID : This contains the LCID setting of the current site.

L_Menu_SiteTheme : This contains the theme name of the current site.

_spUserId : This contains the id of the current user.