Question

I have a SOSL query where I search for an email address in both Contact and Lead SObject. I instruct the query to return some fields like FirstName, MobilePhone, etc., Now, if my SF org does not have the MobilePhone field visibility to true, the query returns "Invalid Column MobilePhone".

Is there a way where I can fetch the available fields for a given object using the Force.com REST API before firing my query?

My SOSL query is

FIND {test@er.com} IN EMAIL FIELDS RETURNING Contact(Phone, Id, Department, Email, isDeleted, Name, MailingCity, Title ), Lead(Id, City, Company, Country, Name, MobilePhone, Phone, State, Status, Street, Title)

No correct solution

OTHER TIPS

You can find the information you need using the SObject Describe functionality or the REST API equivalent, the /services/data/v24.0/sobject/[SObject]/describe REST API Describe call. If a field such as MobilePhone is not in the child "fields" list returned by the REST describe call, then it is not accessible. So if you have a list of fields you would like to return, you should check to see if they are returned in the "fields" list, and not include them in your SOSL query if they are not there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top