Im trying to build a custom job board search on visualforce. I have a positions object which has a relationship has a master detail field to account.

I'd like the search to return positions when you search for company (account names). I know you can use SOSL to search multiple sObject types but id rather it always just return positions. So i made a simple formula field just pulling the org name to the position but it doesnt seem to work.

When i create a text field and then have a trigger fill that in that works fine.. but the trigger feels a lot messier...

is there a way to do this with formulas that will work? or better yet is there a way to search all the "related" fields and still return the specific object?

1 Answer 1


While it looks to be undocumented, formula fields do not appear to be supported by SOSL.

The search() call searches most objects (including custom objects) and text fields to which you have access. It does not search the following objects and fields:

  • Any elements such as picklists that are defined as not searchable (searchable is false). To determine whether a given object is searchable, your application can invoke the describeSObjects() call on the object and inspect the searchable property in the DescribeSObjectResult.
  • Number, date, or checkbox fields. To search for such information, use the query() call instead.
  • Textarea fields, unless you use the ALL FIELDS search group.
  • Attachment records associated with certain objects, such as Account, Contact, or Opportunity.

While triggers and apex sound like quite a lot of overhead, at this point it looks to be the only option to mimic formula field behavior to create a searchable field on your child records.

  • Usually in such case I create a text(255) ext. id field and a simple workflow that synchronizes the value from formula field to the text field on insert & every update. Or just delete the formula field completely and keep the formula only in the field update definition. Bonus points: it makes possible to use the text field in GROUP BY which is impossible with formulas.
    – eyescream
    Dec 19, 2013 at 16:28
  • how do you update all childs when the parent value change with a workflow ? Dec 19, 2013 at 16:58
  • 1
    As long as the formula on child doesn't need any fields from the parent you're fine, right? But if you do - yes, a simple trigger would be needed. Identify Set<id> of accounts on which one of fields referenced in formula have changed and just "touch" them: update [SELECT Id FROM Child__c WHERE Account__c IN :changedSet];. Workflow will take care of actual update.
    – eyescream
    Dec 19, 2013 at 17:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .