I have a context aware (hasRecordId) Lightning component that can be dropped on an undetermined custom object record page. I need the component to grab the recordId, then search for that recordId across all fields of other custom objects. These might be lookup or master-detail, undetermined.
Example schema: let's say my customer has built a recruiting app, with objects including Position, Applicant, and JobApplication. There's a field on JobApplication for Position, and another field for Applicant. But unknown whether it's lookup or master-detail, or maybe just a text field. (I know this is vague, but I won't know what custom schema my customers are using. I'll only be able to dynamically derive recordId and and the custom object to search.)
If I drop my component on an Applicant record page, I want it to search JobApplications -- all fields -- for that recordId. I've been assuming that SOSL is the right approach, since I don't know the fields to search. But... I've discovered that recordId isn't treated as text, so you can't SOSL search on it.
I thought about using schema describe to dynamically pull all the field names from the custom object I'm searching, then do a SOQL search, but a custom object could have hundreds of fields, and that seems like a really bad approach.
I'm aware that Salesforce makes a leap between an Id and the Name sometimes. Like if you link records by Id, it will actually display the Name, not the id. Maybe I'll try using the recordId to pull the record's Name, then SOSL on that?
Any ideas?