+ Start a Discussion

How to Use Custom Setting To Get Name Of Static Resource To Set In <apex:includeStript



I have a custom setting which stored the name of a JavaScript file.  I wish to  get the name from the custom setting and include it when referencing/including a JavaScrpt file in my visualforce page.


I tired to do the following 


<apex:includeScript value="{!URLFOR($Resource[MyCustomObject__c.getInstance(Site.getName()).javaScriptFileName__c])}"/>




<apex:includeScript value="{!$Resource.[MyCustomObject__c.getInstance(Site.getName()).javaScriptFileName__c]}"/>


but these would not save correctly.


For the above requirement, should this be possible, to get a custom setting value at the same time as trying to set it as a resource to load with my visualforce page?


Thanks in advance for any help.

Best Answer chosen by Admin (Salesforce Developers) 
Edwin VijayEdwin Vijay

I think it should be possible. However, you should be getting the value from the custom setting in your controller and then pass it to the VF page i guess


<apex:includeScript value="{!RESOURCEURL}"/>

public String getresourceurl()
    return MyCustomObject__c.getInstance('value');