Introducing sObject-Remote for Visualforce JavaScript Remoting
I’ve been doing a lot more client side dev lately and a big piece of this is working with JavaScript Remoting. While doing this work I found that doing basic CRUD operations with JavaScript Remoting was not as simple as it could be. I didn’t want to have to wire up insert, query, update, and delete functions for each type of salesforce.com object I was working with. I wanted a lightweight and fast JavaScript library that was completely dynamic and allows you to build and entire app client side utitlizing basic CRUD operations.
The result of this need is a small JavaScript library I created called sObject-Remote.
sObject-Remote is up on github now and I encourage you to take a look and kick the tires. There should be plenty of examples in the readme to give you an idea of how this library can be used. Here are a couple basic examples:
Create and Insert a record:
var acct = new sObject('Account',{Name: 'test', Industry: 'Aerospace'}); acct.insert(function(result,event){ console.log(result[0].Id); }); |
Query Records:
sObject.query('select Id, Name, Owner.Name from Account where Industry = \'Aerospace\' limit 5',function(sObjects,event){ //Loop through the records returned by the query for(var i = 0; i < sObjects.length; i++){ console.log(sObjects[i]); } }); |
Some of the highlights:
- Super simple sObject management for JavaScript
- Currently supports 4 basic CRUD operations (more DML operations to come)
- Supports DML options
- Works with any JavaScript framework
- No 3rd party JavaScript library dependencies
A good portion of this development was me becoming more familiar with JavaScript so I am definitely open to community feedback on how to make it better. Please report issues and let me know what you think.




It would be interesting to hear how this compares to Pat Patterson’s work extending the existing REST toolkit to Remoting (described here: http://blogs.developerforce.com/developer-relations/2012/10/not-calling-the-rest-api-from-javascript-in-visualforce-pages.html)
Hey Jeff,
This is sort of address at the very bottom of the github readme.
https://github.com/TehNrd/sObject-Remote#how-is-this-different-from-forcecom-javascript-rest-toolkit
They are very similar. I had no idea that toolkit existed before I started this one.
-Jason
Maybe I’m missing something obvious bit isn’t the Ajax toolkit available for DML from JavaScript?
Ajax toolkit is xml SOAP based. BLECH! Especially when working with JavaScript. Remoting returns everything as JSON.
Ajax toolkit counts agains your API call limit. JavaScript Remoting does not. If you have a Visualforce app that gets a lot of traffic you don’t want it burning through API calls.
From an end user perspective you will never see the XML as the Ajax toolkit converts it to JavaScript objects, but this is slow. Remoting and JSON should be way faster.
Cool man I can’t wait to get a chance to dive into this stuff some more. Your post reminded me of this blog post: http://jefftrull.livejournal.com/3815.html. I’d be interested to try some different benchmarking between the different options.
Hi,
Great Work.I tried your code in my Dev Org but,I have seen my API Requests(“System Overview” Page) were increased . I think JS Remoting does count against API call Limit in Dev Orgs.
API requests don’t increase for me and they shouldn’t for your either. I am 99.99% confident Remoting does not count against API requests but I can’t find the documentation this very moment.
Very good job Jason!