10

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?

1 Answer 1

13

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

2
  • 2
    Jeez.. i must have gone blind :)
    – Prady
    Mar 1, 2016 at 10:15
  • hehe...happens :)
    – ipradhansk
    Mar 1, 2016 at 10:17

You must log in to answer this question.

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