In a List button, i execute javascript code, and for this i defined a static resource where i implemented some functions and i included my resource this way :


and when i use a function that i defined in my resource :

var rows = getCheckedRows(parentForm); 

i have this error after clicking the button :

getCheckedRows is not defined

How can i call correctly the functions that i have defined in my static resource javascript file


The normal way to include JavaScript from a static resource is:

<apex:includeScript value="{!$Resource.uploadFunctions}"/>

Hard coding the static resource upload timestamp (1437644087000) is very fragile.

Check your browser's "Developer Tools" Network tab to see if the JavaScript is loaded and the JavaScript console to see if there are any JavaScript errors.

Your function is probably being defined globally, so to reduce the chances of collision with other JavaScript functions and to make your code read more clearly I suggest you use a distinct naming pattern such as getMyCheckedRows, changing "My" to something relevant to your project.


Sorry, missed that this is in a list button. But the problem of the timestamp being fragile remains. One solution is to use new Date().getTime() to generate the timestamp. This ensures that the latest JavaScript is always re-fetched so you are not using an older version but no caching is ever done.

  • thanks for the answer but i am using the static resource in custom list button not in apex code and it's different – ihssan Jul 23 '15 at 10:27
  • @ihssan Sorry missed that. See the PS. – Keith C Jul 23 '15 at 10:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.