You need to sign in to do that
Don't have an account?
paulkissick
Is it possible to query the text within an attachment using SOQL?
I know it's possible to search attachments from the Web UI, but can I use either SOSL or SOQL to query the attachment object from APEX in order to return a list of records (e.g. contacts) that have an attachment which contains some text i would like to find?
You can access Attachment's data using Body field in Attachment object. The data stored in this field is encoded in base64. You can use EncodigUtil class to decode the data.
Thanks
That's useful to know.
But doesn't solve my issue, sadly.
I'm looking for something like:
List<Attachment> atts = [SELECT Id,ParentId,FileName FROM Attachment WHERE Body LIKE '%Manager%']
Yes but you can retrieve the attachments and then traverse through each attachment to match the required text.
Maurizio,
It's not possible to search attachment object bodies.
I have tried and failed on so many different attempts.
Paul