0

I want to get all the list items that have status "Waiting Approval" and current user is either Manager1 or Manager2.

 <Query>

      <OrderBy>

      </OrderBy>
      <Where>
        <And>
          <Eq>
            <FieldRef Name="Status" />
            <Value Type="Choice">
              Waiting Approval
            </Value>
          </Eq>
          <Or>
            <Eq>
              <FieldRef Name="Manager1ID" />
              <Value Type="Integer">
                <UserID />
              </Value>
            </Eq>

            <Eq>
              <FieldRef Name="Manager2ID" />
              <Value Type="Integer">
                <UserID />
              </Value>
            </Eq>
          </Or>
        </And>

At first it was working when only filtering with Manager with an Or operator. Later i just add an additional condition for the Status but it doesn't return any results.

1

I think you should try:

  <Where>
    <Or>
        <And>
            <Eq>
                <FieldRef Name="Status" />
                <Value Type="Choice">
                    Waiting Approval
                </Value>
            </Eq>
            <Eq>
                <FieldRef Name="Manager1ID" />
                <Value Type="Integer">
                <UserID />
                </Value>
            </Eq>
        </And>
        <And>
            <Eq>
                <FieldRef Name="Status" />
                <Value Type="Choice">
                    Waiting Approval
                </Value>
            </Eq>
            <Eq>
                <FieldRef Name="Manager2ID" />
                <Value Type="Integer">
                <UserID />
                </Value>
            </Eq>
        </And>
      </Or>
    </Where>

  • Thanks for the reply. Still doesn't work . I think it has something to do with the choice field maybe. Should i use the mapping value , so in this case its value 1 for waiting approval , 2 for approved and 3 for rejected – shak Oct 19 '17 at 14:34
  • I found this solution and in text is download for Caml Query builder, so try this way create functional query :) stackoverflow.com/questions/23372443/… – Zdeněk Vinduška Oct 19 '17 at 19:27
  • Solution was to have the Value of choice in the same line as the definition of <Value Type="Choice">Waiting Approval</Value>. Thanks a lot! – shak Oct 20 '17 at 9:07
0

If the Status portion is broken somehow, verify your field name, your field value, and the type of field.

Try the internal field name (if different).

Are you sure it's not "Awaiting Approval" or "Waiting for Approval"?

Is the field type something custom instead of built-in "Choice" field?

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.