Note

All code samples below refer to the skuid object.

In the v2 API, this object is not directly accessible when working within a browser console—or when referring to another Skuid page runtime.

If you are experiencing issues, use the skuid.runtime API to target the appropriate page context.

skuid.sfdc

Collection of utility functions for accessing Salesforce resources through its API, such as performing a SOSL search.

Functions

skuid.service.api()

Make REST API Requests to Salesforce

skuid.service.search(request)

Performs a multi-object search against records in the Salesforce database using SOSL.

Arguments:
  • request (object) – Required. A JavaScript object defining the parameters for your SOSL search request.
Returns:

A jQuery Deferred Promise. When the Promise is either resolved or rejected, it will be handed a search.Result object.

EXAMPLE:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var $ = skuid.$;
var queryText = 'skuid';
// Perform our SOSL Search
$.when(skuid.sfdc.search({
    query: queryText,
    searching: "ALL FIELDS",
    returning: [
       { "objectName": "Account", "fields": ["Name","CreatedDate"] },
       { "objectName": "Contact", "fields": ["FirstName","LastName","CreatedDate"] }
    ]
})).done(function(searchResult){
    $.each(searchResult.results,function(i,sobjectResult){
        var objectName = sobjectResult.objectName;
        var records = sobjectResult.records;
        console.log('* Found ' + records.length + ' ' + objectName + ' records');
        $.each(records,function(j,record){
            if (objectName==='Contact') {
                console.log('Found Contact: ' + record.FirstName + ' ' + record.LastName);
            }
            else console.log('Found Account: ' + record.Name);
        });
    });
}).fail(function(searchResult){
    console.error('Search failed: ' + searchResult.error);
}).always(function(searchResult){
   console.log('Raw SOSL generated: ' + searchResult.sosl);
    console.log('Original search request');
    console.log(searchResult.request);
});

Utility object definitions

Defines the structure of JavaScript objects expected by various functions.

search.Request

Used by skuid.sfdc.search() to define the structure of a desired SOSL search.

PROPERTIES:

  • query (string): Required. The text to search for, e.g. “bacon”. Must be at least 2 characters.
  • returning (array of search.SObjectRequest objects): Required. Defines the Salesforce objects to search against, as well as optionally which fields to return on each object, how to order the returned records, how many records to retrieve per object, and how many records to offset the returned result set by.
  • searching (string): Optional, defaults to “NAME FIELDS”. The type of fields to search within. Must be one of the following: “ALL FIELDS”, “EMAIL FIELDS”, “PHONE FIELDS”, “NAME FIELDS”, “SIDEBAR FIELDS”.
search.SObjectRequest

Used by skuid.sfdc.search() to define which SObjects you want to search as part of a SOSL search.

PROPERTIES:

  • objectName (string): Required. The API Name of an SObject to return records of, e.g. “Account”, “Candidate__c”, “acme__Position__c”
  • fields (array of strings): Optional. The API Names of Fields to return for each record of this SObject that was returned by the search query. For example, [“FirstName”,”LastName”,”Birthdate”,”Account.Name”,”MyCustomField__c”]
  • conditions (array of skuid.Model.Condition objects): Optional. A list of Conditions to use to restrict which matching records are returned by the search query for this object. Used to define the WHERE clause for the generated search query for this SObject. For example, [ new skuid.model.Condition({ field: “IsActive”, value: true, operator: “=”, encloseValueInQuotes: false }) ]
  • conditionLogic (string): Optional. String of logic defining how to apply any Conditions defined in the conditions property, e.g. “1 AND (2 OR 3)”
  • orderBy (string): Optional. A valid SOQL Order By clause defining how to order the results returned by the search query for this SObject. For example, “LastName, FirstName”, or “acme__Position__r.Name DESC NULLS LAST”.
  • recordsLimit (integer): Optional. The maximum number of matching result records to retrieve for this SObject, e.g. 20, 100.
  • recordsOffset (integer): Optional. Used to specify the starting row offset into the result set returned by your query. For instance, if 13 total records of this SObject type are matched by your SOSL search query, and recordsOffset is set to 13, then results 11-13 would be returned (for a total of 3 records).
search.Result

Used by skuid.sfdc.search() to provide the result of a SOSL search.

PROPERTIES:

  • sosl (string): The generated SOSL search query that Skuid used when performing a SOSL search, e.g. “FIND ‘plasma*’ IN ALL FIELDS RETURNING Case(Subject,CaseNumber,CreatedDate), CaseComment(CreatedDate)”
  • request (search.Request object): The original search request object that produced this search result.
  • results (array of search.SObjectResult objects): The results of the SOSL search, for each requested SObject. For instance, if there were two search.SObjectRequest objects specified in the search.Request’s returning property, then there will be two search.SObjectResult objects returned here. NOTE: this will be undefined if there was an error with the SOSL search.
  • error (string): A text description of any error that occurred with the SOSL search. Only populated if there was an error with the SOSL search, otherwise it will be undefined.
search.Resultsearch.SObjectResult

Used by the search.Result object to return the results of a SOSL search for each requested SObject.

PROPERTIES:

  • objectName (string): The API Name of the SObject, e.g. “Account”, “Candidate__c”, “acme__Position__c”
  • records (array of SObject record objects): The SObject records that matched the search query, returned as JavaScript objects containing as properties / fields only those fields specifically requested in the fields property of the search.SObjectRequest.