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
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 + '\')

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.