Example : To write a SOSL query to return both contacts and leads that have first or last name matching with 'Smith'.
Piece Of Code:
string searchString = 'Smith';
List<List< SObject>> recordList = [FIND :searchString IN ALL FIELDS RETURNING Contact(name,id where firstname=:searchString or lastName =:searchString ),Lead(firstname,lastName,name where firstname=:searchString or lastName =:searchString)];
system.debug('recordListrecordList'+recordList);
Output :
Piece Of Code:
string searchString = 'Smith';
List<List< SObject>> recordList = [FIND :searchString IN ALL FIELDS RETURNING Contact(name,id where firstname=:searchString or lastName =:searchString ),Lead(firstname,lastName,name where firstname=:searchString or lastName =:searchString)];
system.debug('recordListrecordList'+recordList);
Output :
No comments:
Post a Comment