0

I am trying to filter two fields or more that is clean of null values.

It works for the first field but it is not working for the second field:

<View><Query><Where><IsNotNull><FieldRef Name='CustomField'/></IsNotNull><IsNotNull><FieldRef Name='LaborCategory'/></IsNotNull></Where></Query></View>
1
  • What is the data type of LaborCategory and CustomField columns? Commented Oct 18, 2020 at 6:34

3 Answers 3

0

You need nested query. For each column you need to add AND/OR in query. See this answer https://stackoverflow.com/a/6204309/4069473

1
  • I tried this solution but got undefined as well
    – kont
    Commented Oct 17, 2020 at 11:13
0

Try using below CAML query:

<View>
  <Query>
    <Where>
      <AND>
        <IsNotNull><FieldRef Name='CustomField'/></IsNotNull>
        <IsNotNull><FieldRef Name='LaborCategory'/></IsNotNull>
      </AND>
    </Where>
  </Query>
</View>

Official documentations:

  1. IsNotNull element (Query)
  2. CAML Query schema
2
  • it does not work actually because am trying to iterate the list to get two results and i think i cant do that, so that i did function for each one
    – kont
    Commented Oct 18, 2020 at 20:16
  • here is what am trying to do after mapping the caml query: while (listItemEnumerator1.moveNext()) { var oListItem1 = listItemEnumerator1.get_current(); $("#labcategory").append('<option>' + oListItem1.get_item('LaborCategory') + '</option>') $("#company").append('<option>' + oListItem1.get_item('CustomField') + '</option>') }
    – kont
    Commented Oct 18, 2020 at 20:17
0

Even though this question is already answered. I would still recommend you to use U2U which will help you create and understand complex CAML queries in the future.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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