Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am running a SOSL Query and i want the results to be order by a particular field.

System.QueryException: unexpected token: ORDER

Here is the query i am building in my apex

FIND 'Cisco Systems*' IN ALL FIELDS RETURNING Account( ownerid,name,website   
WHERE  (name LIKE '%Cisco Systems%' ) OR  (Website_Domain__c LIKE '%cisco.com%' )
OR  (phone LIKE '%4085253777%' ) LIMIT 999 ) ORDER BY Oppty_Count__c LIMIT 2000

Any thoughts?

share|improve this question
up vote 8 down vote accepted

I think you should update your query to

FIND 'Cisco Systems*' IN ALL FIELDS RETURNING Account( ownerid,name,website   
WHERE  (name LIKE '%Cisco Systems%' ) OR  (Website_Domain__c LIKE 
'%cisco.com%' ) OR  (phone LIKE '%4085253777%' ) ORDER BY Oppty_Count__c 
LIMIT 999 ) LIMIT 2000

Just moved the Oppty_Count__c inside the braces. For multiple object types, this needs to be repeated

share|improve this answer
2  
Jeez.. i must have gone blind :) – Prady Mar 1 at 10:15
    
hehe...happens :) – San Tosh Mar 1 at 10:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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