3

I have a sharepoint list ImageList, i have a column which stores its type

The column name is ImageType

the choices are "profile pic","thumbnail" etc

i want to fetch these choice values for this field

i tried accessing it using

http://myintranet:2010/sites/ImagesGallery/_vti_bin/listdata.svc/ImageList?$Select=ImageType&$expand=ImageType

but it is not containing the choice values in it!

How can i get them?

2

To get the choice values from listdata.svc you need to make a request against the correct EntitySet...

You can think of an EntitySet as any list that listdata.svc has access to -- this includes choice field choices.

Choice field EntitySets will typically have an endpoint name that looks like:

<ListName><ChoiceFieldName>

So if I have a list called MyList which has a choice field called MyChoiceField, then a call to the entity set name that can be accessed by listdata.svc would be have an endpoint of:

_vti_bin/listdata.svc/MyListMyChoiceField

To find the precise name of the EntitySet you should be looking for, make a call to the top level endpoint listdata.svc in the site you're interested in.

Use something like:

$.getJSON('../_vti_bin/listdata.svc').then(function(data) { console.log(data) });

In your browser dev tools console, expand the result object. The results should be alphabetical by default, find your list name then below it you should see some more choices for choice fields within that specific list.

When you locate the correct endpoint name, just make a call to that EntitySet name like:

$.getJSON('../_vti_bin/listdata.svc/MyListMyChoiceField')
    .then(function(data) { console.log(data) });

The results to the call against the choice field endpoint will give you a results object which is an Array of objects representing the available choices for that field. You can access the values of the choices by using data.d.results[i].Value in the callback.

  • if you can let me know where i can learn more about this it will be helpful for me – Vignesh Subramanian May 18 '15 at 10:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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