Visualforce Remote Objects

Share on facebook
Share on twitter
Share on linkedin
The Visualforce Remote Objects is a useful tool to quickly create pages with basic data operations and these do not count the API limits. Visualforce Remote Object tags are more suitable for Salesforce1 application.

Visualforce Remote Objects 

  1. The Visualforce Remote Objects is a useful tool to quickly create pages with basic data operations and these do not count the API limits.
  2. Visualforce Remote Object tags are more suitable for Salesforce1 application.
  3. The Visualforce remote objects supports basic DML operations such as Create, Read, Update and Delete in javascript without writing even a single line of apex code.

Click Salesforce: Visualforce Remote Objects to get more details about Visualforce remote objects.

Asset of Visualforce Remote objects:

  1. There is no need for writing Controller and Test classes. Everything will be achieved using the Visualforce page.

Limitations of Visual force Remote objects:

  1. The default Visualforce limits still apply.
  2. You can retrieve a maximum of 100 rows in a single request. To display more records, submit 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>
  1. In the above code, the tag <apex:remoteObjects> tag is mainly used to include everything related to remote objects.
  2. The <apex:remoteObjectModel name=”Account” jsShorthand=”account” fields=”name”> tag is being used to define the object on which the DML operations will be performed.
  3. The jsShorthand attribute defines the shortcut for the object notation that can be used inside the JavaScript code.
  4. The “fields” attribute is used to refer the fields, if you need to add some conditions in your DML operations.

Creating Records using Remote objects:

  1. 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 = { FirstName : ‘AAA’ , lastName : ‘BBB’};
var getRecord = new RemoteObjectModel.Contact();
getRecord.create(createRecord);

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

Retrieve Records using Remote Objects:

  1. We can retrieve the record using 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 RemoteObjectModel.Contact();
getRecord.retrieve ({where : firstname : {‘AAA’}} ;

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

To get more details about Visualforce Remote object, follow the links below:

Visualforce Remote Objects

Remote Objects Callback Functions

Best Practices for using Remote Objects

About MST

At MST Solutions our cornerstone is to adapt, engage and create solutions which guarantee the success of our clients. The talent of our team and experiences in varied business verticals gives us an advantage over other competitors.

Recent Articles

Mobile Responsive Testing

Mobile Responsive Testing is simply a Testing Process performed to make sure that your website or an app is working appropriately on all types of devices.
Whether it an app or website, they need to ensure that they are accessible from any device, anytime, anywhere.

Read Article »

Work with us.

Our people aren’t just employees, they are key to the success of our business. We recognize the strengths of each individual and allow them time and resources to further develop those skills, crafting a culture of leaders who are passionate about where they are going within our organization.