multiple CAML clauses with SPFilterDropdown

Jun 2, 2011 at 1:47 AM

One CAML clause seems to work fine such as

 var filterField2='EndDate';
     var filterField1= 'Status';
     var filterValue2='<Today/>';
     var filterValue1='Open';
     var filterField3='ContentType';
     var filterValue3='Reservations';
     var query =    '<Gt>'+
                    '<FieldRef Name=\''+filterField2 + '\'/>' +                                
                     '<Value Type=\'DateTime\'>' + filterValue2 +'</Value>'+                                                    
                      '</Gt>' +

but when I try to add multiple clauses like the following

var query =                  '<Eq>' +
                                  '<FieldRef Name=\'' + filterField1 + '\'/>' +
                                  '<Value Type=\'Calculated\'>' + filterValue1 + '</Value>' +
                                  '</Eq>' +
                                   '<And>' +
                                  '<Eq>' +
                                  '<FieldRef Name=\'' + filterField3 + '\'/>' +
                                  '<Value Type=\'Computed\'>' + filterValue3 + '</Value>' +
                                  '</Eq>' +
                                  '<Gt>'+
                                  '<FieldRef Name=\''+filterField2 + '\'/>' +                                
                                  '<Value Type=\'DateTime\'>' + filterValue2 +'</Value>'+                                                    
                                  '</Gt>'+
                                  '</And>';                                            

only the first clause is used.  Tried placing the <AND> in different places but nothing seems to work except the first caml EQ clause.    Is there a way to construct the CAML query clauses that will work with more than one condition??

 

Jun 2, 2011 at 2:11 AM

Never mind I solved this  Need to put <And> around the total clause --- and that works fine

Coordinator
Jun 2, 2011 at 12:13 PM
Glad to see you got it!

Try using the U2U CAML Builder to make getting the CAML right easier.

M.
>
Jul 24, 2012 at 3:33 PM

I am trying to do the same thing with the SPCascadingDropdowns. I have tried it with <And></And> wrapped arround my two clauses and without. Neither work. I have tried both clauses individually and they work fine. Any help would be appreciated.

 

Coordinator
Jul 25, 2012 at 3:07 PM

gjstangel:

Can you post what you're trying?

M.