zaterdag, november 25, 2006

Using CAML to filter a infopath published boolean field (from a sharepoint list)

In a infopath form we have a boolean field called Draft, we publish the form to a sharepoint list, and we want to filter that list using Caml queries:
Which value should the BOOLEANVALUE have to succeed the query?
False/True ? Yes/No ? 0/1 ?
What I noticed is, when I published the infopath form the boolean type in intopath will be a Yes/No Type in the sharepoint list.....

So the Caml query will not work with BOOLEANVALUE = False/True Or Yes/No , you have to use 0 or 1...

Implement the CAML query into code:

StringBuilder camlBuilder = new StringBuilder();

string queryText = camlBuilder.ToString();

SPWeb site = SPContext.Current.Web;
SPList list = site.Lists["Mail"];
SPQuery query = new SPQuery();
string queryText =""
query.Query = queryText;

results = list.GetItems(query);
foreach (SPListItem item in results)
{..............}

If you put the query Tag as root tag into the query text, you will receive all items, zo don't put it there, some stupid guy I know very good did that ;-)

Also check this out:
U2U CAML Query Builder and Execution Tool (+download)

2 opmerkingen:

Andy B zei

Yes, I'd exactly the same problem. It's ridiculous. A boolean field should be true or false.

custom sharepoint development zei

Nice piece of information... thanks for sharing this issue...