You need to sign in to do that
Don't have an account?
Mentee
SOSL query - Lookup fields
String query = 'FIND \'*' + searchString + '*\' IN ALL FIELDS RETURNING Ticket__C (Region__r.name, Manager__c, Manager__r.name, Name, Notes__c), user(id,Name)';
I am searching with user name and results are zero.
Aim: when a string is entered, it should match with any of the fields of ticket and display the results. with the above query, it will match only with Ticket.name and shows zero results when i am searching for the user.name. any inputs please
I am searching with user name and results are zero.
Aim: when a string is entered, it should match with any of the fields of ticket and display the results. with the above query, it will match only with Ticket.name and shows zero results when i am searching for the user.name. any inputs please
Manager__c is a Lookup(User).
This how I should do?
Ticket__c[] searchTickets= (Tickets__c[])searchList[0];
User[] searchUser = (User[])searchList[1];
in for loop user(){
if(user.name == manager name in ticket){
addTolistToDisplay.add(ticket__c object);
}
or any other efficient way I can do this?
All Answers
In SOSL you can't search by string value of a Lookup field.
For Example:
Record in object Contact:
Name: David Sidhu
Now there's a related object "LookUpToContact" looking up to parent object Contact.
Try to search "David Sidhu" using SOSL in LookUpToContact Query:
String searchName = 'FIND {David*} IN ALL FIELDS RETURNING LookUptoContact__c(Id, Contact__r.FirstName)';
Returns nothing, just an error (can be verified using workbench).
https://help.salesforce.com/articleView?id=000176100&type=1
I have a search which has to find given string from the Ticket object which also has lookup field to user.
If input is a user name, they should be able to see ticket records related to the user, which I am displaying on visualforce.
Manager__c is a Lookup(User).
This how I should do?
Ticket__c[] searchTickets= (Tickets__c[])searchList[0];
User[] searchUser = (User[])searchList[1];
in for loop user(){
if(user.name == manager name in ticket){
addTolistToDisplay.add(ticket__c object);
}
or any other efficient way I can do this?