[SalesForce] Can we have a ORDER BY Clause in SOSL

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?

Best Answer

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

Related Topic