Clay Visualforce Connector for Clay-Model

Usage no npm install needed!

<script type="module">
  import clayModelVfr from '';



Clay Visualforce Connector for Clay-Model


clay-model-vfr uses Clay for Salesforce Package Available in App Exchange. There is a package that works with RemoteTK Component.


npm install clay-model-vfr


Register this Connector with Clay-Model at initialization

var ClayVfr = require("clay-model-vfr");

var Model = require("clay-model");
var User = Model.configure("User", ["name", "email"])
User.ajax = ClayVfr;


Read Clay-Model docs for Model API


Execute a SOQL Query

User.query( SOQL )
    .then( function(){
        var users = User.all()
    .fail( function(error){
        // Salesforces API Error Structure


Use Clay-Model regularly, behind the scenes it is sending all CRUD's to via Visualforce Remoting

Only thing to note, if you don't want to send changes to the servers, use { ignoreAjax: true }

var user = User.create({name: "rob"}, {ignoreAjax: true}){ ignoreAjax: true });

Visualforce Remoting

Because sometimes is useful to wrap Visualforce Remoting Calls inside a Model, we included the Api Method.

User.api( remoteAction, argument1, argument2, argumentn,  options );

remoteAction: [STRING] The remote action you want to execute in the form ClassName.MethodName

arguments: optional arguments to be send to RemoteAction.

options: [OBJECT] Options for Visualforce Remoting Configuration

options.nullok: [BOOLEAN] Don't raise error if VFR response is null. Default: false -> will raise error is response is null

## Packages for ISV's

When the app is part of a package simple add the following line

User.ajax.namespace = "NAMESPACE.";

This must be done for each model. Notice the (.) at the end of the namespace, it is required.

## Clay for Salesforce

To use Clay-Model-VFR with Clay for Salesforce the namespaces work as follows:

[]( App Exachange Instalation ) NAMESPACE = threevot.ThreeVotApiController

[]( Manual Instalation - No Updates ) ThreevotApiController

[]( Open Source ) ThreevotApiController or you Package if using in Managed Package