Asynchronous Javascript Using Visualforce

Visualforce May 6, 2015

Using Javascript we can perform DML Operation on Salesforce Asynchronously with the help of Visualforce pages, let's work on Read operation listed below.

Before getting started please follow listed steps,

  1. Create a Visualforce Page
  2. Add connection.js library, dont forget to pass SessionId, how to do that explained below
<!--you can add your own Controllers, for demoing purpose making it as easy as possible-->
<script src="/soap/ajax/28.0/connection.js" type="text/javascript"></script> 

Example Explained

Include following line of statements under <script> tags

sforce.connection.sessionId = "{!$Api.Session_ID}"; 
var result = sforce.connection.query("Select Name,Id from User", {
    onSuccess: function(result) {
        var records = result.getArray("records");
        // Iterate over records to view them
        for (var i = 0; i < records.length; i++) {
            var record = records[i];
            log(record.Name + " -- " + record.Id);
    onFailure: function(error) {
        log("An error has occurred " + error);

Happy coding comment below if you need any help

Looking for more clik here

Phanindra Mangipudi

Salesforce, Lightning Web Componets, Node.Js, Angular 2+, Bootstrap