You need to sign in to do that
Don't have an account?
sfadm sfadm
How to include the contents of a static resource file in controller class?
I have a controller class with the following method implementation:
In the Static Resource I have a file called "Stylesheet" with content:
public String buildTemplate(Task task) { Id taskId = task.Id; List<Task_History__c> listTaskHistory = [SELECT Field1, Id, Field2, Username__c, LastModifiedDate FROM Task_History__c WHERE Task_ID__c = :taskId]; String pageHTMLContent = '<HTML><HEAD><STYLE>{! $Resource.Stylesheet }</STYLE></HEAD><BODY><TABLE class="css_class">'; pageHTMLContent += '<TR><TH>Comment1</TH><TH>Comment2/TH><TH>Last Modified By</TH><TH>Last Modified Date</TH>'; for(Task_History__c taskHistory :listTaskHistory) { String oldValue = taskHistory.Old_Value__c; String newValue = taskActivityHistory.New_Value__c; String userName = taskActivityHistory.Username__c; DateTime lastModifiedByDate = taskActivityHistory.LastModifiedDate; pageHTMLContent += '<TR>'; pageHTMLContent += '<TD>' + oldValue + '</TD><TD>' + newValue + '</TD><TD>' + userName + '</TD><TD>' + lastModifiedByDate + '</TD>'; pageHTMLContent += '</TR>'; } pageHTMLContent += '</TABLE></BODY></HTML>'; return pageHTMLContent; }I'd like to know how to include the contents of a static resource file in controller class?
In the Static Resource I have a file called "Stylesheet" with content:
table.css_class , .css_class th, .css_class td { border: 1px solid black; padding: 10px; } table.css_class th { text-align: center; }Please advise how to include the contents of a static resource file in controller class?
SOQL
REST API
Refer this link
https://salesforce.stackexchange.com/questions/107584/accessing-static-resource-in-apex
http://forceguru.blogspot.com/2012/05/static-resource-url-in-apex.html