0

SP 2010. I have a value "East & West" and list name Region. How do I handle special characters?

here is the caml that breaks

  <ViewFields>
    <FieldRef Name='ActionStatus' />
  </ViewFields>
  <Where>
    <Eq>
      <FieldRef Name='Region' />
      <Value Type='Choice'>East & West</Value>
    </Eq>
  </Where>
3

This is not a special character issue.

You cannot combine Contains element with Choice field type.

Try Eq element instead:

<ViewFields>
  <FieldRef Name='ActionStatus' />
</ViewFields>
<Where>
  <Eq>
    <FieldRef Name='Region' />
    <Value Type='Choice'>East & West</Value>
  </Eq>
</Where>
| improve this answer | |
0

As per this blog, it's stating that you wrap your special text in <![CDATA[ TEXT ]]>.

So in your situation it would be <![CDATA[East & West]]>.

For others that are building CAML queries programically, you can split the string and add your variable as normal.

const direction = "East & West";
const camlString = '<Value Type="Choice"><![CDATA[' + direction + ']]>';

However, are you sure that your type choice is correct and shouldn't be something like Text? Normally choice is reserved for drop-downs, from what I recall.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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