Between in Spservices with multiple date fields

Asked

Viewed 64 times

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>

He basically does:

See a Sharepoint 2013 list that contains several columns of dates, and in the form there are several fields of the date type.

The problem is that the between the way I built it, it returns nothing. Just an error that Calmquery is incorrect.

Does anyone know how to do a Calmquery with multiple date fields?

1 answer

0

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

<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, worth using, mainly to validate the Query’s https://github.com/bandrben/SPCAMLQueryHelperOnline

Browser other questions tagged

You are not signed in. Login or sign up in order to post.