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
Srinu@dreamsSrinu@dreams 

Java Script for custom buttons in salesforce

{!REQUIRESCRIPT("/soap/ajax/24.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}
{!REQUIRESCRIPT("{!URLFOR($Resource.jquery)}")}

 

 

Where can I find "/soap/ajax/24.0/connection.js", "/soap/ajax/20.0/apex.js" these files in salesforce?

What is the purpose of using these files?

Ankit AroraAnkit Arora

If I've uploaded a javascript file in static resource and want to use it on visualforce page then we use

<apex:includeScript>

tag, right? So these files are exactly the same :-)

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

Shivanath DevnarayananShivanath Devnarayanan

Hello,

 

These are Javascript Wrappers around the Force.com API, which allow you to make Calls to your apex code, enable you for javascript remoting etc.

 

learn more about Apex in AJAX go here and to learn about the AJAX toolkit go here

 

and to answer the second part of your question, these javascripts are built in and cannot be modified, but you can view them by typing it directly in your browser

 

Connection.js : https://ap1.salesforce.com/soap/ajax/25.0/connection.js

Apex.js : https://ap1.salesforce.com/soap/ajax/25.0/apex.js

 

replace the ap1 instance with your server instance.

 

hope it helps !

 

/* Please mark it answered if it helped you, so that it may help someone else */

 

TrinayTrinay

Hi Srinu,

   These are the AJAX toolkit includes built-in support for invoking Apex through anonymous blocks or public webService methods.

 

For example:

           If you want to call the Apex class by button click in the standard page layout, we can use these functions:

apex class:

----------------

global class myClass

{
  webService static Id makeContact(String lastName, Account a)

  {

    Contact c = new Contact(LastName = lastName, AccountId = a.Id);
    return c.id;
  }

}

 

Button:

----------

 Create the button with the behaviour of Execute Javascript. and add the following:

 

{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}

sforce.apex.execute("myClass","makeContact",{lastName:"Smith",a:account});

 

**I hope this will helpful for you**