shareplum
                                
                                 shareplum copied to clipboard
                                
                                    shareplum copied to clipboard
                            
                            
                            
                        'And' condition don't work correctly
Where rule didn't work correctly for more then 2 conditions.
If I use few conditions to get list elements, like this:
    Where: [
        ('Eq', Field1', 'Value1'),
        ('Eq', Field2', 'Value2'),
        ('Eq', Field3', 'Value3'),
    ]
then SharPlum will return elements for 1st condition, other conditions will be ignored.
Same result I will get if I use 'And' condition, like this:
    Where: [
        ('Eq', Field1', 'Value1'),
        'And',
        ('Eq', Field2', 'Value2'),
        'And',
        ('Eq', Field3', 'Value3'),
    ]
But if I add 'And' mark like this:
    Where: [
        'And',
        ('Eq', Field1', 'Value1'),
        ('Eq', Field2', 'Value2'),
        ('Eq', Field3', 'Value3'),
    ]
I will get error response from SOAP:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Server</faultcode>
      <faultstring>Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.</faultstring>
      <detail>
        <errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/">Cannot Complete this action</errorstring>
        <errorcode xmlns="http://schemas.microsoft.com/sharepoint/soap/">0x80004005</errorcode>
      </detail>
    </soap:Fault>
  </soap:Body>
</soap:Envelope>
For two conditions it seems work fine...
Seems, there are common limitations on queries:
CAML query can contains at most two comparison statement inside <OR> or <AND> block.
So. after "googling" the solution looks like include multiple conditions in top-level condition, like this (for 3 conditions):
    Where: [
        'And',
        ('Eq', Field1', 'Value1'),
        'And',
        ('Eq', Field2', 'Value2'),
        ('Eq', Field3', 'Value3'),
    ]
For more conditions it would be like this:
    Where: [
        'And',
        ('Eq', Field1', 'Value1'),
        'And',
        ('Eq', Field2', 'Value2'),
        'And',
        ('Eq', Field3', 'Value3'),
        'And',
        ('Eq', Field4', 'Value4'),
        'And',
        .......
        'And',
        ('Eq', FieldM', 'ValueM'),
        ('Eq', FieldN', 'ValueN'),
    ]
May be it would be good to process this on SharePlum side?
Also, there is no ability to close conditions like 'And' and 'Or'. So if I want to make more comlicate condition, it would be problematic.
Interesting. Top notch work on this. Do you have any suggestions on improving the syntax for these queries?
Do you have any suggestions on improving the syntax for these queries?
Query syntax may be like this:
query = {
    'Where': [
        ('And', [
            ('Eq', 'Field1', 'Value1'),
            ('Eq', 'Field2', 'Value2'),
            ('Eq', 'Field3', 'Value3'),
        ]),
        ('Eq', 'Field4', 'Value4'),
    ]
    'OrderBy': ['Field1']
}
And I think that your script must provide normal work of incorrect number of conditions by itself, in another words control number of conditions in 'AND'-block and break them into nested conditions, e.g.:
query = {
    'Where': [
        ('And', [
            ('Eq', 'Field1', 'Value1'),
            ('And', [
                ('Eq', 'Field2', 'Value2'),
                ('Eq', 'Field3', 'Value3'),
            ])
        ]),
        ('Eq', 'Field4', 'Value4'),
    ]
    'OrderBy': ['Field1']
}
But anyway it's not transparent how first condition (AND-block) related to second condition for field4.
+1 ran into this problem
@gwsampso Can you describe the query you are trying to run?