2

I changed a field from being a single line of text, to being a lookup (still only displaying a single line of text, but it's fetched from another list. The field's internal name is Status. This is where I get an error:

oListItem.get_item('Status');

The error reads:

The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.

So I changed this line

clientContext.load(listItemCollection);

to

clientContext.load(listItemCollection, 'Include(Status)');

Now, the executeQueryAsync's failure handler is called with the following error:

Value does not fall within the expected range.

Any ideas what might be causing this? The code worked before I changed the column type, so the problem shouldn't be with any other code...

Edit:

Based on Dikesh Gandhi's suggestion, I tried adding the following to my caml query:

<View><ViewFields><FieldRef Name="Status" /></ViewFields></View>

But then the original error (not initialized) returned, regardless of if I have the include-string passed to the load function.

4
  • try to access with oListItem.get_item('Status').get_lookupValue() May 20, 2016 at 12:38
  • This makes no difference, still getting the same error. May 20, 2016 at 12:41
  • Add status in ViewFields in caml query. May 20, 2016 at 12:44
  • I tried this (see my edit), but it resulted in the first error again. May 20, 2016 at 12:55

3 Answers 3

1

It seems there can be few causes as mentioned below.

  1. Use of invalid field name. You need to use the internal field name!
  2. Change the List View Lookup Threshold value of the web application. Default value is 8.
5
  • 1
    The internal name is correct. The List View Lookup Threshold is at 12, but what exactly does this value mean? May 20, 2016 at 12:39
  • @aegarn this value determines how much lookup values are fetched (in case there are more than x lookup columns on a list item). i had the same problem recently and i had to raise the threshold from 16 to 22 until i finally got the field value because our users add tons of fields to lists, thereby making a bigger lookup threshold necessary for the js to work properly.
    – garglblarg
    May 20, 2016 at 14:35
  • The list only has 2 lookup fields, so a threshold of 12 should be enough, right? May 20, 2016 at 15:56
  • 1
    It is more than enough.
    – Hardik
    May 20, 2016 at 16:12
  • 1
    You need to put your source code so i can understand it & help you further on the same... :)
    – Hardik
    May 20, 2016 at 16:13
0

Is that column is lookup and display type ? please check column name in list seetings as columnName:title. If so need to change the column reference

6
  • The display name in list settings is "Current phase", but if I click it I can see the internal name in the status bar: &Field=Status May 20, 2016 at 12:58
  • oListItem.get_item("Country").get_lookupValue(); In this country is the look up column for the list.
    – user27178
    May 20, 2016 at 13:37
  • is that you have selected the checkbox below "Add a column to show each of these additional fields:" the dropdown , inorder to select the columns for look up . if so please remove that . and simply select the column only .
    – user27178
    May 20, 2016 at 13:39
  • I did have one column checked in Add a column to show each of these additional fields:, but removing that made no difference, unfortunately. May 20, 2016 at 13:49
  • How you have changed the single line colum to look up as we get only Single line of text Multiple lines of text Choice (menu to choose from) Number (1, 1.0, 100) Currency ($, ¥, €) Date and Time , these options only.
    – user27178
    May 20, 2016 at 14:05
0

Are you on 2010 or 2013?

Status is the internal fieldname of SharePoints default Task Status feld on 2013

So if you create a new Field Status it will be Status0 (or was it 1 ?) for the Internal Name

8
  • 2013. It returns the same error for both Status0 and Status1 unfortunately. And if I put them in the Include string, I get Column 'Status1' does not exist. It may have been deleted by another user. May 20, 2016 at 13:45
  • Go into the settings of the field and check the URL, it will use the internal fieldname in the URL May 20, 2016 at 13:56
  • The url says Field=Status May 20, 2016 at 13:58
  • Double check: Go check the internal name for the default (Task)Status field in the Site Column definitions or open a default Tasks List and check the field in the List Settings... here is my screenshot of a default Tasks List (on Office365) which shows the internal name as ''Status'' in the URL. You can not have identical internal names. May 20, 2016 at 14:32
  • 1
    It's a Custom list, not a Tasks list, so that field isn't present. May 20, 2016 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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