Loading...
New Awarded Winner – IT & Development | Payoneer India 2026 Check out
Featured Recognized by Salesforce; Proven by impact! Check out

In the Spring’14 release, Salesforce had announced the support for JavaScript with its popular Visualforce Remoting feature. Visualforce Remoting was introduced to ease database operations such as create, read, update and delete in Javascript without using Apex or counting API request limits.

Used for building web apps with Visualforce, JavaScript Remoting is a popular, powerful and efficacious method. It enables the users to create pages to use in Salesforce1 or work with JavaScript libraries like jQuery or AngularJS efficiently.

Visualforce Remote Objects

Visualforce Remote Objects helps in the basic DML operations on sObjects from the JavaScript. They are the proxy objects that ease the JavaScript Remoting by cutting down the use of @RemoteAction methods in an Apex controller or extension.

Visualforce Remote Objects consists of the following:

  • Access definitions: 

Using the new Remote Objects components, Access definitions are written in Visualforce and generate a set of JavaScript proxy objects.

  • Data access functions: 

Written in JavaScript, Data Access functions use the proxy objects that are made available by the access definitions to perform create, select, update, and delete operations on the data.

For Live Demo on Create Account Using Remote Object Click Here

 

For Live Demo on Retrieve Accounts Using Remote Object Click here

Using Remote Objects in JavaScript

Remote Object Components generate Javascript models that provide JavaScript API to create functions for the apps that can read and save values back to Salesforce. One of the remote object components is <apex:remoteObjects> component that creates the base model to instantiate specific models for corresponding sObjects. These specific models enable multiple actions such as retrieving, creating, updating, and deleting to be performed on their sObjects.

The name of the base model created is sObjectModel by default and can be changed later using the jsNamespace attribute.

Basic description of Visualforce Remote Objects:-

  • Enables the user to create pages with basic data operations without content the API request limits.
  • Its tags are more suitable for Salesforce1, jQuery and AngularJS.
  • Supports basic DML operations such as Create, Read, Update and Delete in javascript without writing even a single line if apex code.
  • Controller and test classes are not required to be written anymore as it can be achieved using the Visualforce page.

Limitations of Visualforce Remote Objects

  • Though it provides new capabilities, Visualforce Remote Objects is not a complete feature yet.
  • Remote Objects have limitations of their own as they are subject to change without providing backward compatibility.
  • Remote Objects enables you to retrieve a maximum of 100 rows only in a single request. To display more records, you need to submit an additional request by using the OFFSET query parameter.

Example:

<apex:remoteObjects>

<apex:remoteObjectModel name=”Account” jsShorthand=”account”    fields=”Name,Id,FirstName,LastName,Phone,Rating”>

              </apex:remoteObjectModel>

</apex:remoteObjects>

Detail description above example :-

  • <apex:remoteObjects> : Used to include everything related to remote objects.
  • <apex:remoteObjectModel name=”Account” jsShorthand=”account” fields=”name”>: Used to define the object on which the DML operations will be performed.
  • jsShortHand attribute: Defines the shortcut for the object notation that can be used inside the JavaScript code.
  • “fields” attribute: Used to refer the fields to add conditions in the DML operations.

Creating Records suing Remote objects:

  • create() is used to create a record on a Remote Object instance.

RemoteObjectModel.create({field values},  Callback function)

The field values block defines the record to create in one statement.

Example :-

var createRecord = { Name : ‘AAA’};

var getRecord = new RemoteModel.account();

getRecord.create(createRecord);

create() does not return a result directly. Callback function is used to handle the server response.

Retrieve Records using Remote Objects:

  • We can retrieve the record suing the retrieve() function in remote object.

var getRecord = new SobjectModel.account();

First we need to initialize the remote objects and it is applicable for our DML operation method.

Example:-

var getRecord = new SobjectModel.account();

getRecord.retrieve( { where : name : {‘AAA’}} );

retrieve() does not return a result directly. The callback function enables you to handle the server response.

Create Account via Remote Object

VisualForcePage:

Retrieve Account via Remote Object VisualForcePage:

Conclusion

  • Visualforce Remote Objects are the best and lightest way to perform rapid client-side querying without impacting API limits. Here is everything you need to know about Retrieve Accounts and Create Account via Remote Objects. Please feel free to reach out to us at sales@hicglobalsolutions.com should you have any queries in programming.

    Happy Learning!

Related Articles

Sticky notes aren’t just for your desk anymore! In this tutorial, we’ll create a Lightning Web Component (LWC) in Salesforce that allows you to pin notes on your app page or record page. With a clean, interactive UI, these digital sticky notes ensure you never forget important tasks or details. What Will You Learn? By […]

Read More
How to Create Dynamic, Animated Charts in Salesforce LWC using Chart.js

Bring Salesforce data to life with dynamic charts inside Lightning pages! While Salesforce dashboards are powerful, sometimes business users want visual insights without leaving their current page. That’s where Chart.js with Lightning Web Components (LWC) becomes a game-changer. In this step-by-step guide, you’ll learn how to: Upload Chart.js as a static resource in Salesforce. Build […]

Read More
How to Encrypt and Decrypt Data in Salesforce Using Apex Crypto Class

Data security is more important than ever. Whether you’re storing customer information, sensitive business data, or private communication, ensuring that your data stays safe is critical. Salesforce provides built-in tools to help with this, and one of the most powerful yet easy-to-use approaches is encryption and decryption using the Apex Crypto class. In this blog, […]

Read More
Benefits & Step-by-Step Setup Guide for Salesforce Code Analyzer

When building on the Salesforce platform, code quality and security are non-negotiable, especially before submitting your app for a Salesforce Security Review. Catching bugs and vulnerabilities early not only saves time but also ensures compliance with Salesforce’s best practices. That’s where the Salesforce Code Analyzer comes in. This open-source tool scans your Apex classes, triggers, […]

Read More
A Step-by-Step Guide to Integrate Zoho CRM with Salesforce (Without Coding)

Managing data across multiple CRMs can be a real challenge for businesses that want a single source of truth. If your teams use Zoho CRM but want to move or sync all records seamlessly into Salesforce, you don’t need to write a single line of code. Thanks to MultiSync Made Easy, the integration process is […]

Read More
How to Integrate Salesforce with Copilot

Integrating Salesforce with Copilot is becoming an essential step for organizations aiming to streamline workflows, automate client data management, and unlock the power of AI-driven CRM. By connecting these two platforms, businesses can centralize customer information, reduce manual tasks, and accelerate growth. This guide walks you through the Salesforce–Copilot integration process with clear steps, Apex […]

Read More