You need to sign in to do that
Don't have an account?
MSS
Should SOSL searches return child Contact records of Accounts that match the search criteria when returning only Contacts?
Should SOSL searches return child Contact records of Accounts that match the search criteria when returning only Contacts?
Let's say you have an Account and Contact records represented by the following code:
Let's say you have an Account and Contact records represented by the following code:
Account smithServices; Contact jane; Contact mary; Contact michael; smithServices = new Account(Name = 'Smith Services'); insert smithServices; jane = new Contact(FirstName = 'Jane', LastName = 'Ada', Account = smithServices); mary = new Contact(FirstName = 'Mary', LastName = 'Smith'); michael = new Contact(FirstName = 'Michael', LastName = 'Smith'); insert new List<Contact>{jane, mary, michael};Then perform the following SOSL search returning only Contact records:
List<List<SObject>> searchList = [FIND 'smith' IN NAME FIELDS RETURNING Contact(Name)]; for (SObject contact : searchList[0]) { System.debug(contact); }The Contact records returned from the SOSL search are:
Contact:{Name=Michael Smith} Contact:{Name=Mary Smith} Contact:{Name=Jane Ada}I would expect the 'Jane Ada' Contact to not be in the results because that record doesn't include a name field that matches the search criteria. It looks like it is included in the search results because the parent Account record's Name field matches the search criteria. Is this expected behavor?
It is not logical but for Contact and Opportunity (at least), there is this wrong behavior.
AccountId = searchPrefilterable = true, The searchPrefilterable field of the fields property now indicates whether a foreign key can be included in prefiltering when used in a SOSL WHERE clause. Prefiltering filters by a specific field value before executing a full search query.
... perhaps this wrong behavior is linked with the property searchPrefilterable = true of AccountId (side effect ?) but Case is not affected.
One workaround (not your question) is to filter the results but that is a problem because of the limit of 2,000 records reduced by this wrong behavior.
I didn't find the rule for this wrong behavior in the documentation of SOSL by using these specific relationships between standard objects and the SOSL requests IN NAME FIELDS.
The following code working for me. I think you should try this.
This is the output of my code.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
I also want to start the coding, how should I begin? Waiting for response
myccpay login (https://cashbytes.org/myccpay-login)