You need to sign in to do that
Don't have an account?
Mark Crooks
Is it possible to search for an exact match only?
Hi, Could anyone tell me whether this is possible?
I'm wanting to check whether an account name already exists within my SF database.
Let's say I have an existing account named "Test Computers", when I submit a search for 'Test' only I DON'T want Test Computers to be included in the results.
"FIND {"Test"} IN Name FIELDS RETURNING account (account.Id)"
Thanks,
Mark
I'm wanting to check whether an account name already exists within my SF database.
Let's say I have an existing account named "Test Computers", when I submit a search for 'Test' only I DON'T want Test Computers to be included in the results.
"FIND {"Test"} IN Name FIELDS RETURNING account (account.Id)"
Thanks,
Mark
SOSL matches fields based on a word match while SOQL performs an exact match by default (when not using wildcards). For example, searching for 'Digital' in SOSL returns records whose field values are 'Digital' or 'The Digital Company', but SOQL returns only records with field values of 'Digital'.
However, workaround that you may take is that let SOSL return all the results then iterate over those results and compare the value that you search against particular field. If match found store in separate list. I am not sure how much this works for your scenario but please do let me know if it works.
Thanks
All Answers
SOSL matches fields based on a word match while SOQL performs an exact match by default (when not using wildcards). For example, searching for 'Digital' in SOSL returns records whose field values are 'Digital' or 'The Digital Company', but SOQL returns only records with field values of 'Digital'.
However, workaround that you may take is that let SOSL return all the results then iterate over those results and compare the value that you search against particular field. If match found store in separate list. I am not sure how much this works for your scenario but please do let me know if it works.
Thanks
what if you run SOQL instead of SOSL ?
Thanks,
Himanshu
Salesforce Certified Developer | Administrator | Service Cloud Consultant
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.