You need to sign in to do that
Don't have an account?

Get content of a static resource from withing a trigger
Anyone know how I could get the contents of a static resource, a text file, from within a trigger. You can't create a PageReference and then use the getContent().toString() method - that's not allowed from within a trigger.
Thanks in advance for any assistance
Hey
You should be able to select the contents as you would with other object types e.g.
List<StaticResource> sr = [Select body, name from StaticResource where Name = 'xx'];
Cheers,
Wess
All Answers
Hey
You should be able to select the contents as you would with other object types e.g.
List<StaticResource> sr = [Select body, name from StaticResource where Name = 'xx'];
Cheers,
Wess
Wess, you rock!
Shame on me for not at least looking at the data model to see if Static Resources were an exposed object.
Thanks again,
Bob
Static resources are query-able via Apex, so you can extract the contents of a static resource after query and looping through the query results.
Please find attached the sample query:-
Select s.Id, s.Body From StaticResource s
I have a text file in static resources. when I ran this query, I found the body is either encoded or encrypted. Any idea how it is stored in the databse? Thanks