A few weeks ago I started messing around with different Javascript libraries and put them up on Github as the Javascript Playground.

Well, lo and behold, it turns out I wasn’t the only one curious about some of these.  Lot’s of people are working in the area. In fact, one person has gone so far as to share their very excellent code with the project.

Kevin Poorman, aka @CodeFriar on Twitter and IRC, has created a very flexible “ngForce” library. His sample code creates an extremely easy to use filter for Opportunities and provides a nice modal dialog for the one the user is focusing on.  I’ve integrated this into the playground for your enjoyment.

Now, this example is a fun thing all by itself, showing what you could do with his creation, but the library actually includes a great deal of important functionality.  Here’s Kevin’s top 3 — the rest you can find by perusing the code.

1. Promise based API — ngForce lets you take advantage of the Javascript common promise API.  This makes it easier for you to handle complex, multi-query operations, without having to manually handle AngularJS digest operations until all of your queries are complete.  This minimizes the possibility of seeing a “digest already in process” error, a common frustration for AngularJS developers. Further, you can count on multiple asynchronous API queries being executed in a predictable order.

2. Bulk load handling — ngForce gives you a new utility method that handles bulk data insertion.  The method, “bulkCreate”, takes two key arguments.  First, is the API name of the object you want to insert data into, and the second is the data itself.  It also accepts standard success and failure callback methods, but relies primarily on the promise API.

3. Field set handling — ngForce understands the concept of Visualforce field sets, and gives you multiple utilities that help you take maximum advantage of them.  For example, you can pass in a field set name, and ngForce will return a properly constructed SOQL query based on that field set.  Also, given an object and field set name, ngForce will go and query the object automatically if that’s what you need.


ngForce includes a lot more — things like automatic Select2 field creation and automatic picklist generation.  You should take a deeper dive.

Thanks for sending this along Kevin — keep up the great work!

You can get install CodeFriar’s code and the rest of the examples (jQuery, jQuery Mobile, Backbone, and Bootstrap) your into your dev org using a package link on the Github repo.

Questions, comments?  Would love to hear them.

@ReidCarlberg

tagged , , , Bookmark the permalink. Trackbacks are closed, but you can post a comment.
  • http://twitter.com/abhinavguptas Abhinav Gupta

    Interesting library for sure, liked the JS promises support, this pattern is good thing to inspire and use in other remoting calls in visualforce page.

  • http://twitter.com/ewu Eric Wu

    Awesome! This is why Kevin’s an MVP!

  • mailtoharshit