speed of skuid.sfdc.search() vs. dynamic model .initialize().register().load()

  • 1
  • Question
  • Updated 12 months ago
  • Answered
I need to dynamically (with Javascript) get the value of a single field from an object.

What's the most economical way to accomplish that?

I can use skuid.sfdc.search to return the row, or I can dynamically build a skuid model and query it. My assumption is that the former would be faster (less overhead?). Can anyone confirm or deny?

Here's my search function. the variable 'code' that I'm using as the search term contains the value of the "Optimize_Code__c" field, which is unique for each row in the object.
var getNavVisibility = function(){
            var dfd = new $.Deferred();
            $.when(skuid.sfdc.search({
                query: code,
                searching: "ALL FIELDS",
                returning: [{"objectName": "Navigation_Menu_Set__c", "fields": ["Id", "Name", "Optimize_Code__c", "Profile_Visibility__c"]}]
            })).done(function(searchResult){
                var records = searchResult.results.length && searchResult.results[0].records;
                if (records && records.length){
                    dfd.resolve(records[0].Profile_Visibility__c);
                } else {
                    dfd.reject();
                }
            }).fail(function(searchResult){
                console.error('Search failed: ' + searchResult.error);
                dfd.reject(searchResult.error);
            }).always(function(searchResult){
                console.log('Raw SOSL generated: ' + searchResult.sosl);
                console.log('Original search request');
                console.log(searchResult.request);
            });
            return dfd.promise();
        };
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 12 months ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
The dynamic model load would be faster because you can limit to just a specific row with a model condition --- as long as you know the id of the row you want. This should return really fast because it's using a database index.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Good to know! Thanks.