Examples for writing SOQL queries

edited July 4, 2017 in Questions
Are there any good examples that can be referred for writing SOQL query in skuid in-line snippet and then show the soql results in skuid table?


  • edited December 18, 2014
    I don't believe that you can write SOQL queries in an JavaScript snippet. Skuid uses models as soql. The syntax concept is, SELECT fields FROM models WHERE conditions. You can call apex methods from Javascript, but in my experience most soql scenarios can be handled with models.
  • edited March 2, 2017
    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

  • edited May 11, 2015
    How can i get data from model.With java script.
  • Rob HatchRob Hatch 🛠️ 
    edited September 1, 2016
  • edited May 11, 2015
    I have already check.Please check my code


         var params = arguments[0],
            step = params.step,
            stepEditor = step.editor,
          $ = skuid.$;
        var contactModel=skuid.model.getModel("AddContact");
        var raw=contactModel.getFirstRow();
        var Firstname=raw.FirstName;
        var Middlename=raw.MiddleName;
        var LastName=raw.LastName;
        var Birthdate=raw.Birthdate;
        var Name='';
            Name+=' '+Middlename;
            Name+=' '+LastName;
        if(Firstname===undefined  || LastName===undefined){
            alert('Please Enter First Name, Last Name');
            return false;
    var Agcontact=skuid.model.getModel("Agcontact");
    var FirstNamecondition = Agcontact.getConditionByName('FirstName');
    var Middlenamecondition = Agcontact.getConditionByName('MiddleName');
    var LastNamecondition = Agcontact.getConditionByName('LastName');

        var bd=new Date(Birthdate); 
        var ageDifMs = Date.now() - bd.getTime();
        var ageDate = new Date(ageDifMs); // miliseconds from epoch
        var age=Math.abs(ageDate.getUTCFullYear() - 1970);
        alert("Candidate’s age is less than 18");   
    var Birthdatecondition = Agcontact.getConditionByName('Birthdate');



        var messages = [];
        var msg = [];
        msg.message=Name+' is already registor.Do you want to continue?...Click me';
    if (messages.length) {
        var r = confirm(Name+' is already registor');
        if (r === true) {
            return true;
        } else {
              return false;



Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!