You need to sign in to do that
Don't have an account?
Chamil Madusanka
access static resource in APEX class
Hi All,
We can access static resources in visualforce page as follows;
{!URLFOR($Resource.UploadTemplate)}
How can we access the static resource in APEX class?
Thanks in Advance!
you can't access $resource in apex script.. if you want that file to be used from apex you need to place as a document and use it in apex...
Hi,
How to place that file as a document in salesforce?
go to all tabs section in that you find the document tab .. click on that and create a new document .....
Hi,
How can I access the file which uploaded as a document, in APEX class?
you can query the document object
lstDoc = [select id,name from Document where name = 'test'];
The standard technique for accessing Document Tab files in Apex is not working for me.
Here's the code I'm using:
Donations_Test_Data is the "Document Unique Name" (i.e. API name) of a CSV file stored in the Documents Tab. This SOQL query produces zero (0) records of output.
The log looks like this:
I need to be able to access this test data programmatically in order to get test coverage.
Static Resources aren't stored in the Documents object, they are in the StaticResource object. Just change your code to this:
@Tsunami Sailor
How can find data inside zip (Content type application/x-zip-compressed ) as static resource?
2. Converted the json file to apex using - http://json2apex.herokuapp.com/.
3. Copied the class from step 2 into the main class "SandboxPostCopy".
4. public static JSON2Apex parse(String $staticresource.xyz) { return (JSON2Apex) System.JSON.deserialize($staticresource.xyz, JSON2Apex.class);
I am not sure step 4 coding is correct or not (I am trying to access the xyz static resource json file) .. once I read this file .. I want to update the custom settings based on the json file values.. please guide me with the coding... how to read and how to access the file xyz. Thanks.
String strBody = sr.Body.toString();