Using CAML Query on an External Data column hooked through BCS?

We have created a new Document Library that has a BCS connection to External Data source to reference data relating to the added documents. (Released version of SP2013)

There is a NameID field used as the External Data that we can see in the display list which shows the results we expect on all items in the list.

However, when we try to build a CAML query from the CSOM to filter on this NameID field, it doesn't work.

Examples of what we have tried. (these all return every item in the list, we just want them ones that have a NameID=10633)

<Query><Where><Eq><FieldRef Name='NameID' LookupId='True' /><Value Type='Lookup'>10633</Value></Eq></Where></Query>

<Query><Where><Eq><FieldRef Name='NameID' /><Value Type='Lookup'>10633</Value></Eq></Where></Query>

<Query><Where><Eq><FieldRef Name="NameID" /><Value Type="BusinessData">10633</Value></Eq></Where></Query>

There are two other columns we include through the BCS that we can run a CAML query on and get the expected results.

This works ok on "NameID: TypeDesc" which is from the same external data source

<Query><Where><Contains><FieldRef Name="NameID_x003a__x0020_TypeDesc" /><Value Type="Note">Ex-</Value></Contains></Where></Query>

Is it not possible to run a CAML query on the 'primary' External Data column?

Thank you.

February 6th, 2013 2:26am

The lookup column is copying the data in as text. Try this:

<Query><Where><Eq><FieldRef Name="NameID" /><Value Type="Text">10633</Value></Eq></Where></Query>

Scot

Free Windows Admin Tool Kit Click here and download it now
February 6th, 2013 3:03pm

Still the same results when using Type="Text". It still wants to return all the items in the list ignoring the <Eq>.

Thank you for the idea.

February 6th, 2013 9:08pm

It's working for me. I'm looking at it right now. Don't include LookupId in the CAML.

Scot

Free Windows Admin Tool Kit Click here and download it now
February 6th, 2013 10:08pm

Hi Scot,

I am having the same issues when running a CAML query on a Sharepoint 2013 list and querying using the Business Data Column.  Its completely ignoring the EQ and returning all rows.

I have tried a Value Type of Text and BusinessData and both have the same result.

Is there anything else you could suggest.

Many Thanks in advance

July 8th, 2013 6:53am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics