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
g-mang-man 

Search returns empty (null) object

When using the search() method, I get a record back representing my search but the field values are all empty or null. What am I missing here? Here is a code snippet:

SearchResult search = _sforceService.search(
"find {Greg} in NAME fields returning User");
SearchRecord[] records = search.searchRecords;

for (int i = 0; i < records.Length; i++)
{
sObject record = records[i].record;

if (record.GetType() == typeof(User))
{
User u = (User)record;
queryResults.Items.Add("User : " + u.FirstName + " " + u.LastName + " | " + u.Email);
}
}

It returns one User object but all fields are null. Any ideas? I've used the query() method without any problems.

Thanks!
SuperfellSuperfell
All the fields are null, because your SOSL query didn't include any fields to return.