function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mds_tanvimds_tanvi 

add javascript on button click

Hi  guyz,

i wanna call a javascript method written in a js file on a custom button button click but m not able to add my javascript file. I have included the javascript file in the static resources. But can anyone help me how i can add the static resources on the click of the custom button. 

Any help would be highly appreciated ... 

 

 

Alok_NagarroAlok_Nagarro

Hi Tanvi,

 

First you need to include that java script file in the page .

Ex- if you are stored your js file with name of MyJavascriptFile in static resources then you can include like this -

 

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

 

And if you stored a zip folder (given name -LibraryJS) in static resource, then you need to pass also the path of file in respect to zip folder like -

 

<apex:includeScript value="{!URLFOR($Resource.LibraryJS, '/base/subdir/file.js')}"/>

 

 

Now you can use the function defined in that file.

Santhosh KumarSanthosh Kumar

I assume you asking about, how to include your Javascript file into the Standard layout pages. There is no direct way to do it as of now. There are some hacks like specifying the script tab as part of the Section name etc. Search inthe forums and you will find more details about it.