Select to view content in your preferred language

query.where issu

1006
12
Jump to solution
05-14-2013 02:42 AM
khadijaahal_el_fadl
New Contributor
Hi , i try to query  on more than one field, I want to have somthing like
"query.where= "field1='"+value1+"'" && "field2='"+value2+"'" ; but it doesn't work, it consider just the last field :it works as it was one only field wich is the last one.  if you have Any idea please
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor
Try this instead

if( val1&&val2){q.where="p_from='"+val1+"' AND p_to='"+val2+"'";}

View solution in original post

0 Kudos
12 Replies
VinayBansal
Occasional Contributor II
Try putting "AND" instead of "&&" in where clause
0 Kudos
khadijaahal_el_fadl
New Contributor
Try putting "AND" instead of "&&" in where clause


thank you for replying , but I had already tried it and it doesn't work too.
0 Kudos
ReneRubalcava
Frequent Contributor II
Is that your exact query?
This query.where= "field1='"+value1+"'" && "field2='"+value2+"'" is a boolean expression, true or false.
Is this the exact code you are using?
It should be formed as query.where = "field1='" + value1 + "' AND field2='" + value2 + "'"
Try to test it via the Query REST page and see if it works as expected.
0 Kudos
khadijaahal_el_fadl
New Contributor
Is that your exact query?
This query.where= "field1='"+value1+"'" && "field2='"+value2+"'" is a boolean expression, true or false.
Is this the exact code you are using?
It should be formed as query.where = "field1='" + value1 + "' AND field2='" + value2 + "'"
Try to test it via the Query REST page and see if it works as expected.


Hi,thank you for replaying. I tested the  query as you suggested  in the REST page and I had an error:
"{
  "error" :
  {
    "code" : 400,
    "message" : "Unable to complete  operation.",
    "details" : [
      "Unable to complete Query operation."
    ]
  }
}"
0 Kudos
ReneRubalcava
Frequent Contributor II
I think if a field value is numeric, you can eliminate the single quotes, could be an issue. Tough to diagnose without looking at the data. How about if you do one query a time, without trying to combine them?
0 Kudos
khadijaahal_el_fadl
New Contributor
I think if a field value is numeric, you can eliminate the single quotes, could be an issue. Tough to diagnose without looking at the data. How about if you do one query a time, without trying to combine them?


I teied this  on the rest page :
field1='value1' AND field2='value2'
and it works
0 Kudos
khadijaahal_el_fadl
New Contributor
the problem is that when I use the "AND" in JS code , it's not recognized. Have you any idea about that?
0 Kudos
KenBuja
MVP Esteemed Contributor
Can you post what isn't working in your code?
0 Kudos
khadijaahal_el_fadl
New Contributor
Can you post what isn't working in your code?

"
var val1=this.widgets.textSearch.getValue();
var val2=this.widgets.exp.getValue();
if( val1&&val2){q.where="p_from='"+val1+"'" &&"p_to='"+val2+"'";} "

I've tried to replace "&&" withe "AND" but still not working
0 Kudos