0

I am trying to use the existing LWC with some modifications to get records on the basis of RecordType.Id but it's throwing an error instead. System.QueryException: expecting a right parentheses, found 'Y000000Wl0yQAC'.

Apex:

tring searchKeyword = searchTerm + '*';
        
        String returningQuery = '';
        returningQuery = objectName+' ( Id, '+String.join(fields,',')+' WHERE RecordType.Id = '+recordTypeId+' )';
        String query = 'FIND :searchKeyword IN ALL FIELDS RETURNING '+returningQuery+' LIMIT 20';

The resultant String query is FIND :searchKeyword IN ALL FIELDS RETURNING Account ( Id, Rating,AccountNumber,Name WHERE RecordType.Id = 0120Y000000Wl0yQAC ) LIMIT 20

How to fix this??

1 Answer 1

1

You need quotes around string values, including ID values:

FIND :searchKeyword 
IN ALL FIELDS 
RETURNING Account ( 
  Id, Rating, AccountNumber, Name 
  WHERE RecordType.Id = '0120Y000000Wl0yQAC') 
LIMIT 20

You must log in to answer this question.