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

In this detailed guide, we will walk you through the significant yet easy steps to configure Email to Salesforce. Without any further ado, let’s get started! About Email to Salesforce As the term refers, Email to Salesforce is valuable for any organization that businesses use as their Customer Relationship Management (CRM) platform. It helps streamline […]

Read More
Guide on CRUD Operations in Node.js with jsForce

CRM developers typically need to integrate Salesforce with Node.js apps. One well-known library for this purpose is jsForce, which provides a comprehensive set of tools for interacting with Salesforce data and performing CRUD tasks effectively. Let’s dive into the blog, where you will understand the use of jsForce to execute key CRUD tasks within Salesforce, […]

Read More
How to Implement Round Robin Assignments in Salesforce Using Apex

Ensuring a proper workload balance and quick follow-ups from internal or external team members, leads, opportunities, or task distributions is crucial. To achieve this, all you need is a Round Robin assignment. In this step-by-step guide, we will walk you through the process of implementing a round-robin assignment in Salesforce using Apex. Here, we’ve used […]

Read More
Best Salesforce Developments Services Provider

In this step-by-step guide, we will walk you through the significant role of Large Data Volumes in Salesforce, and what strategies or practices you should keep in mind. What is Large Data Volumes? In Salesforce, Large Data Volumes (LDV) refers to managing a huge amount of records available in the platform. LDV usually comes into […]

Read More

Salesforce Apex includes numerous built-in text handling classes, and in addition to them, the Pattern and Matcher classes are good for performing complex string operations. These classes enable us to define and work with regular expressions, which are of particular importance for data validation, searching, and modification. In this technical blog, we will find out […]

Read More

Maintaining security and compliance in Salesforce requires effective user access management. This article will lead you through the process of creating expiration dates for Permission Sets and Permission Set Groups, allowing you to automate access removal while minimizing manual work. Know how this functionality simplifies workflows, guarantees compliance, and improves security procedures. Why Use Expiration […]

Read More
Our Location worldwide
Indian Flag India
3rd Floor, A-10, Pegasus Tower, Sector 68, Noida, Uttar Pradesh 201301 +91-1203117884
United States of America Flag USA
333 West Brown Deer Road Unit G – 366 Milwaukee WI, USA 53217 +1(262) 310-7818
United Kingdom Flag UK
7 Bell Yard, London, WC2A 2JR +44 20 3239 9428
Canada Canada
HIC Global Solutions INC
43 Lafferty Lane, Richmond Hill, L4C 3N8, CA +1(262) 310-7818