Between in SPServices with multiple date fields

0

I have the following CALMQuery.

<Query>
 <Where>
  <Or>
     <Or>
        <Or>
           <Or>
              <Or>
                 <Eq>
                    <FieldRef Name='Title' />
                    <Value Type='Text'>Titulo</Value>
                 </Eq>
                 <Geq>
                    <FieldRef Name='Vencimento_x0020_Certid_x00e3_o_' />
                    <Value Type='DateTime'>txtDataDeCNDTribMobil</Value>
                 </Geq>
                 <Leq>
                    <FieldRef Name='Vencimento_x0020_Certid_x00e3_o_' />
                    <Value Type='DateTime'>txtDataAteCNDTribMobil</Value>
                 </Leq>
              </Or>
              <Geq>
                 <FieldRef Name='Vencimento_x0020_CND_x002f_INSS' />
                 <Value Type='DateTime'>txtDataDeCNDINSS</Value>
              </Geq>
               <Leq>
                 <FieldRef Name='Vencimento_x0020_CND_x002f_INSS' />
                 <Value Type='DateTime'>txtDataAteCNDINSS</Value>
              </Leq>
           </Or>
           <Geq>
              <FieldRef Name='Vencimento_x0020_CRF' />
              <Value Type='DateTime'>txtDataDeCRF</Value>
           </Geq>
           <Leq>
              <FieldRef Name='Vencimento_x0020_CRF' />
              <Value Type='DateTime'>txtDataAteCRF</Value>
           </Leq>
        </Or>
        <Geq>
           <FieldRef Name='Vencimento_x0020_CND_x0020_Tribu' />
           <Value Type='DateTime'>txtDataDeCNDTribFederais</Value>
        </Geq>
        <Leq>
           <FieldRef Name='Vencimento_x0020_CND_x0020_Tribu' />
           <Value Type='DateTime'>txtDataAteCNDTribFederais</Value>
        </Leq>
     </Or>
     <Geq>
        <FieldRef Name='Vencimento_x0020_Seguro_x0020_de' />
        <Value Type='DateTime'>txtDataDeSegurodeVida</Value>
     </Geq>
     <Leq>
        <FieldRef Name='Vencimento_x0020_Seguro_x0020_de' />
        <Value Type='DateTime'>txtDataAteSegurodeVida</Value>
     </Leq>
  </Or>
   </Where>
    <OrderBy>
       <FieldRef Name='Title' />
    </OrderBy>
 </Query>

It basically does:

Query a 2013 Sharepoint list that contains multiple date columns, and in the form there are several date fields.

The problem is that the between in the way I put it together, does not return anything. Only one error that CALMQuery is incorrect.

Does anyone know how does a CALMQuery with multiple date fields?

    
asked by anonymous 09.06.2014 / 19:39

1 answer

0

Then all your conditions have to use OR If yes, your CAML is wrong the right would be like this:

<Where>
  <Or>
    <Or>
      <Or>
        <Or>
          <Or>
            <Or>
              <Or>
                <Or>
                  <Or>
                    <Or>
                      <Eq>
                        <FieldRef Name='Title' />
                        <Value Type='Text'>Titulo</Value>
                      </Eq>
                      <Geq>
                        <FieldRef Name='Vencimento_x0020_Certid_x00e3_o_' />
                        <Value Type='DateTime'>txtDataDeCNDTribMobil</Value>
                      </Geq>
                    </Or>
                    <Leq>
                      <FieldRef Name='Vencimento_x0020_Certid_x00e3_o_' />
                      <Value Type='DateTime'>txtDataAteCNDTribMobil</Value>
                    </Leq>
                  </Or>
                  <Geq>
                    <FieldRef Name='Vencimento_x0020_CND_x002f_INSS' />
                    <Value Type='DateTime'>txtDataDeCNDINSS</Value>
                  </Geq>
                </Or>
                <Leq>
                  <FieldRef Name='Vencimento_x0020_CND_x002f_INSS' />
                  <Value Type='DateTime'>txtDataAteCNDINSS</Value>
                </Leq>
              </Or>
              <Geq>
                <FieldRef Name='Vencimento_x0020_CRF' />
                <Value Type='DateTime'>txtDataDeCRF</Value>
              </Geq>
            </Or>
            <Leq>
              <FieldRef Name='Vencimento_x0020_CRF' />
              <Value Type='DateTime'>txtDataAteCRF</Value>
            </Leq>
          </Or>
          <Geq>
            <FieldRef Name='Vencimento_x0020_CND_x0020_Tribu' />
            <Value Type='DateTime'>txtDataDeCNDTribFederais</Value>
          </Geq>
        </Or>
        <Leq>
          <FieldRef Name='Vencimento_x0020_CND_x0020_Tribu' />
          <Value Type='DateTime'>txtDataAteCNDTribFederais</Value>
        </Leq>
      </Or>
      <Geq>
        <FieldRef Name='Vencimento_x0020_Seguro_x0020_de' />
        <Value Type='DateTime'>txtDataDeSegurodeVida</Value>
      </Geq>
    </Or>
    <Leq>
      <FieldRef Name='Vencimento_x0020_Seguro_x0020_de' />
      <Value Type='DateTime'>txtDataAteSegurodeVida</Value>
    </Leq>
  </Or>
</Where>

Another tip, there is a tool that you can simulate Query in CAML in the SharePoint lists, it is worth using, mainly to validate Query's link

    
25.09.2014 / 05:25