Skip to main content
Post Merged (destination) from sharepoint.stackexchange.com/questions/24300/…
edited tags
Link
Eric Alexander
  • 43.4k
  • 10
  • 55
  • 93
Tweeted twitter.com/#!/StackSharePoint/status/61460828041383937
added 474 characters in body
Source Link
DrZ
  • 171
  • 3
  • 4
  • 12

I'm using SPServices to query a list, using CAML, and the column I'm searching (Title) have values that contains < and >.

Is there anyway I can use CAML to find these values? It seems that I'm getting undefined returned. If the string doesn't contain these characters, I get exactly what I want back.

Using U2U CAML Query Builder, it returns this CAML:

<Query><Where><Eq><FieldRef Name="Title" /><Value Type="Text">Value &lt; 10</Value></Eq></Where></Query>

where the value of title is actually Value < 10.

Thank you very much,

dave


Here is my solution that worked for me.

var a = "Test & < > '10'"; 

var newA = a.replace(/&/g, "&amp;").replace(/</g,"&lt;").replace(/>/g, "&gt;").replace(/'/g,"&#039;").replace(/"/g, "&quot;");

Then I pass in newA to my SPServices call where I'm using CAML to find my data.

CAMLQuery: "<Query><Where><And><Eq><FieldRef Name='title'/><Value Type='Text'>" + newA + "</Value></Eq>" ....

I'm using SPServices to query a list, using CAML, and the column I'm searching (Title) have values that contains < and >.

Is there anyway I can use CAML to find these values? It seems that I'm getting undefined returned. If the string doesn't contain these characters, I get exactly what I want back.

Using U2U CAML Query Builder, it returns this CAML:

<Query><Where><Eq><FieldRef Name="Title" /><Value Type="Text">Value &lt; 10</Value></Eq></Where></Query>

where the value of title is actually Value < 10.

Thank you very much,

dave

I'm using SPServices to query a list, using CAML, and the column I'm searching (Title) have values that contains < and >.

Is there anyway I can use CAML to find these values? It seems that I'm getting undefined returned. If the string doesn't contain these characters, I get exactly what I want back.

Using U2U CAML Query Builder, it returns this CAML:

<Query><Where><Eq><FieldRef Name="Title" /><Value Type="Text">Value &lt; 10</Value></Eq></Where></Query>

where the value of title is actually Value < 10.

Thank you very much,

dave


Here is my solution that worked for me.

var a = "Test & < > '10'"; 

var newA = a.replace(/&/g, "&amp;").replace(/</g,"&lt;").replace(/>/g, "&gt;").replace(/'/g,"&#039;").replace(/"/g, "&quot;");

Then I pass in newA to my SPServices call where I'm using CAML to find my data.

CAMLQuery: "<Query><Where><And><Eq><FieldRef Name='title'/><Value Type='Text'>" + newA + "</Value></Eq>" ....
Source Link
DrZ
  • 171
  • 3
  • 4
  • 12

How to query using CAML when a value has < in the value

I'm using SPServices to query a list, using CAML, and the column I'm searching (Title) have values that contains < and >.

Is there anyway I can use CAML to find these values? It seems that I'm getting undefined returned. If the string doesn't contain these characters, I get exactly what I want back.

Using U2U CAML Query Builder, it returns this CAML:

<Query><Where><Eq><FieldRef Name="Title" /><Value Type="Text">Value &lt; 10</Value></Eq></Where></Query>

where the value of title is actually Value < 10.

Thank you very much,

dave