Examples for writing SOQL queries

In general, the recommended approach is to create Models and Components in your Skuid page declaratively using the Page Composer, and then JavaScript can be used to interact with the Models and Components, e.g. re-query a Model, changing Models’ Conditions, rerendering a Component, etc.

You don’t have to load data into Models on initial page load, you can always set “Load Model data on page load” to false, and then query for / load the data later when you are ready using JavaScript, e.g.

var myModel = skuid.model.getModel(‘MyModel’);
myModel.updateData(); // run the Model’s query

This has many benefits, but one of the big ones is that you don’t have to write a SOQL query — you build your Model, and Skuid builds a SOQL query when it needs to using the current state of the Model — so if you’ve activated / changed Conditions on your Model, Skuid will create a corresponding SOQL string to match the state of the Model. I think you’ll find that you’ll save yourself a lot of string manipulation hassle by not writing SOQL queries in JavaScript.

BUT, if you really need to create dynamic Models or Components client-side — there are use cases for this, but they are very very rare — here is a tutorial that will help you do this: Dynamic creation of Models and Components from JavaScript