none
REST API unable to retrieve custom lookup value RRS feed

  • Question

  • Hi,

    I'm trying to retrieve a list item that contains an extended lookup field. For some reason I'm keep geting this error:

    The field value for field "fieldname" of type "fieldtype" cannot be serialized.

    The only real customization of the field is that it has altered rendering and thus far it been working just fine.

    This is my sample REST query:

    jQuery.ajax(
    {
    	url: "/_api/web/lists/getByTitle('MyList')/items/",
    	dataType: "json",
    	data: "$filter=startswith(ContentTypeId, '" + parentCtId.id + "')",
    	processData: false,
    	headers: { ACCEPT: "application/json;odata=verbose" },
    	async: false
    }).done(function (data)
    {
    }).fail(function (e)
    {
    });
    Any ideas of what might be missing?

    Tuesday, July 30, 2013 6:50 AM

Answers

All replies

  • Hi Valdas,

    Please check the following,

    http://www.andrewconnell.com/blog/Applying-Filters-to-Lookup-Fields-with-the-SP2013-REST-API

    Best Regards.


    Kelly Chen
    TechNet Community Support

    Wednesday, July 31, 2013 2:50 AM
    Moderator
  •  Hi,

    I am facing a similar issue.

    Above article link only discusses about how to filter using REST API in case or normal lookup.

    However, the real issue comes when I am trying to get data for a custom lookup field type. This is giving me a serialization error.

    I need an immediate resolution for same, an early reply is appreciated.

    -Aditya

    Tuesday, February 11, 2014 6:26 PM
  • Hi, Vildas!

    Do you have found solution?

    Thursday, February 13, 2014 6:36 AM
  • I found solution:

    Override FieldValueType in the class of the custom field type:


    public class MyCustomLookup : SPFieldLookup
    {
    ////////////
    
        public override Type FieldValueType
        {
            get
            {
               return typeof(string);
            }
        }
    
    ////////////////
    }
    
    After this value is serialized

    • Proposed as answer by Shai Petel Wednesday, February 4, 2015 3:57 PM
    Friday, March 7, 2014 6:07 AM
  • Thanx for the solution. It worked :)
    Friday, July 4, 2014 5:52 AM
  • But then i get a rendering problem (lookup not a link) when list is used as a webpart on a webpart-page:

    Tuesday, September 20, 2016 2:37 PM
  • We have the same issue. We spent a lot of time - the only way to fix the webpart render by using jslink: a part of solution:

    .FilteredMultiXXFieldViewTemplate = function (ctx, field, listItem, listSchema) {    ctx.CurrentFieldSchema.Type = "LookupMulti";    LookupFieldRenderer(field.RealFieldName);    return LookupFieldRendererRenderField(ctx, field, listItem, listSchema);}


    Also we found this answer:

    "Custom field types aren't supported in the REST API. Microsoft has been trying to get us away from using them for a little while now. While powerful, they are too deep of a customization."

    https://disqus.com/home/discussion/andrewconnell/applying_filters_to_lookup_fields_with_the_sharepoint_2013_rest_api/


    • Edited by Marc H Tuesday, October 11, 2016 8:00 AM
    Wednesday, September 21, 2016 12:59 PM