You need to sign in to do that
Don't have an account?
TSME
SOSL bind variable in apex not working anymore
We have a lightning component that does a looup on the asset object based on input in a text field.
Until yesterday we had following code in our apex controller to perform the query:
String searchString = '\'*'+userInput+'*\'';
String soslQuery = 'FIND :searchString IN ALL FIELDS RETURNING '
+ type +'(Id, name,SerialNumber ORDER BY name'+') LIMIT 20';
List<List<SObject>> results = Search.query(soslQuery);
However today we noticed that this code isn't working anymore as the results list is always empty.
Replacing the soslQuery code with the following fixes the issue:
String soslQuery = 'FIND ' + searchString + ' IN ALL FIELDS RETURNING '
+ type +'(Id, name,SerialNumber ORDER BY name'+') LIMIT 20';
What are wemissing? Isn't a bind variable not supported anymore in these kind of queries? Or is there anything wrong in the use of them?
Regards,
Thomas
Until yesterday we had following code in our apex controller to perform the query:
String searchString = '\'*'+userInput+'*\'';
String soslQuery = 'FIND :searchString IN ALL FIELDS RETURNING '
+ type +'(Id, name,SerialNumber ORDER BY name'+') LIMIT 20';
List<List<SObject>> results = Search.query(soslQuery);
However today we noticed that this code isn't working anymore as the results list is always empty.
Replacing the soslQuery code with the following fixes the issue:
String soslQuery = 'FIND ' + searchString + ' IN ALL FIELDS RETURNING '
+ type +'(Id, name,SerialNumber ORDER BY name'+') LIMIT 20';
What are wemissing? Isn't a bind variable not supported anymore in these kind of queries? Or is there anything wrong in the use of them?
Regards,
Thomas
below is working for me
Your code .. Space was issue
Thanks for your answer, but my main question is why following code isn't working anymore, while it was before:
So using a bind variable instead of your solution, as that one is working for me too.
However until 2 days ago above code was running fine in production, but suddenly we don't get any results anymore.
Replacing it with similar code as your example works fine..