0

How to write the below SOQL Query in JavaSCript

SOQL Query:

select  Country,CountryCode,Latitude,Longitude  from Lead Where (Latitude!=null or  Longitude!=null) AND Country= 'IN'

In JavaSCript:I have tried to implement the above SOQL in JavaSCript,But It's not working .Can anyone help me

 var a='IN';
 var strQuery="SELECT Name, Id,Latitude,Longitude,Country from Lead where Country =\'"+ a + "\'+" AND (Latitude!=null or  Longitude!=null) limit 10";
   var result = sforce.connection.query(strQuery);

Error:Uncaught SyntaxError: Unexpected identifier at AND (Latitude!=null or Longitude!=null)

3
  • usually, when you say not working, there is an error message associated to it, after you have id'd the error, you should be able to identify the root cause and correct it (or at least try)
    – glls
    Sep 7, 2017 at 14:51
  • Thanks, It is throwing Uncaught SyntaxError: Unexpected identifier at AND (Latitude!=null or Longitude!=null) limit 10";
    – Manikon
    Sep 7, 2017 at 14:56
  • please update your post accordingly ;)
    – glls
    Sep 7, 2017 at 14:56

1 Answer 1

2

You've an extra +" before AND. Can you try the below one?

var a='IN';
var strQuery = "SELECT Id,Name,Latitude,Longitude,Country from Lead where Country =\'"+ a + "\' and (Latitude!=null or  Longitude!=null) limit 10";
var result = sforce.connection.query(strQuery);

Hope this helps.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .