Accessing SharePoint 2010 BCS lists via SOAP/WebServices for use in a jQuery autocomplete

So it seems that you can’t access BCS list data via REST, according to this article. But it seems that you can access the list data through SOAP. I used the code below to query a BCS list that points to a MSCRM 2011 backend (I know I could go right to CRM via REST, but then I would have XSS issues). I then take the results and use them for a jQuery autocomplete for an input box. Obviously in the code below, Contacts is a BCS “external List”

 


$('#ContactSearchTextbox').autocomplete({
source: function( request, response ) {
	$().SPServices({
	operation: "GetListItems",
	async: false,
	listName: "Contacts",
	CAMLViewFields: "<ViewFields><FieldRef Name='FullName' /><FieldRef Name='ContactId' /><FieldRef Name='ParentCustomerIdName' /></ViewFields>",
	CAMLQuery: "<Query><Where><Contains><FieldRef Name='FullName' /><Value Type='Text'>"+request.term+"</Value></Contains></Where></Query>",
	completefunc: function (xData, Status) {
	$('#SearchResults').html(xData.responseText);
	response($.map( $(xData.responseXML).SPFilterNode("z:row"), function( item ) {
	return {
	label: $(item).attr('ows_FullName') + "(" + $(item).attr('ows_ParentCustomerIdName') +")",
	value: $(item).attr('ows_ContactId')
		}
	}));
	}
	});	    
},
minLength: 4
});

,

2 Responses to Accessing SharePoint 2010 BCS lists via SOAP/WebServices for use in a jQuery autocomplete

  1. Adam March 5, 2013 at 3:31 pm #

    Can this be done in SharePoint 2007? Any guidance on search typeahead code that can be used to go against a SharePoint list.

    Trying to develop an interactive FAQ for support that will show results that reference the Question and the content of the answer and provide links to that content if there is a match.

    Adam

  2. jbmurphy March 5, 2013 at 4:49 pm #

    I am not sure. I know BCS is not in 2007, but I can’t find any reference to CSOM and BDC. If the data is in a list, and not in an external connection, then you may be able to use SPServices