2

I am trying to display related contacts on the record detail page based on the current Contact record id. For the related contacts, my SOSL as follows:

String searchQuery = 'FIND \''  + firstName + ' OR ' + lastName + 
                         '*\' IN ALL FIELDS RETURNING Contact(Name,Email,AccountId WHERE Id != \' '+ contId + '\') LIMIT 10';
    List<List<sObject>> relCons= search.query(searchQuery);

I am passing firstName, lastName and contId as parameters to the method.

Error I get on the VF page (on the contact record detail page):

Content cannot be displayed: invalid ID field: 0033500000XXXXXXXX

0

2 Answers 2

4

You seem to have an extra space in your query, right after the opening quote in the where clause.

Turn != \' '+ contId + '\') into != \''+ contId + '\')

2

You injected a leading space:

RETURNING Contact(Name,Email,AccountId WHERE Id != \' '+ contId + '\')
                                                     ^

So the invalid filter value looks like: ' 003...'. Remove this leading space:

RETURNING Contact(Name,Email,AccountId WHERE Id != \''+ contId + '\')

You must log in to answer this question.

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