function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Reppin__505Reppin__505 

Returning SOSL Results

Hello,

 

I have a custom object and i am trying to search that custom object using SOSL.

 

Now when i debug i can see that there are results for that custom object, but i am unable to pull those results, i simply don't know the correct syntax. Can you help?

 

 

List<List<sObject>> searchClassHistory = [FIND 'Note' IN ALL FIELDS RETURNING Classes__c(Parent_Id__c, Originating_Id__c, Type__c, Title__c, Body__c, Original_Created_Date__c Where Parent_Id__c = :a.Id)];
		}		

 

    	for(List<sObject> records: searchClassHistory)
    	{
			for(sObject record : records)
				{
					tempList.add(record);
					System.debug('SEARCHING THE HISTORY ' + record);
					
				}	
    	}

 

The loop to extract the results is not working. Any ideas?

 

Imran MohammedImran Mohammed

I see nothing wrong in your code.

As you said that you were able to view the results, Did you try to output searchClassHistory and see if it is empty?

If not try that and see. 

What i feel is that SOSL might be returning 0 records.

Reppin__505Reppin__505

Hello Imran, what i see in the debugger is sosl is returning 3 records. But i am having a hard time accessing those records. The  method of using these sobject loops came from the text book and it should be working. So i don't know what i'm doing wrong.