8

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?

11

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
    Jeez.. i must have gone blind :) – Prady Mar 1 '16 at 10:15
  • hehe...happens :) – San Tosh Mar 1 '16 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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