Skip to main content
Nintex Community Menu Bar
Question

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

  • July 11, 2024
  • 2 replies
  • 8 views

Forum|alt.badge.img+18

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(){<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var dfd = new $.Deferred();<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $.when(skuid.sfdc.search({<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; query: code,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; searching: "ALL FIELDS",<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; returning: [{"objectName": "Navigation_Menu_Set__c", "fields": ["Id", "Name", "Optimize_Code__c", "Profile_Visibility__c"]}]<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })).done(function(searchResult){<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var records = searchResult.results.length &amp;&amp; searchResult.results[0].records;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (records &amp;&amp; records.length){<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dfd.resolve(records[0].Profile_Visibility__c);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dfd.reject();<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }).fail(function(searchResult){<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.error('Search failed: ' + searchResult.error);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dfd.reject(searchResult.error);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }).always(function(searchResult){<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.log('Raw SOSL generated: ' + searchResult.sosl);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.log('Original search request');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.log(searchResult.request);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return dfd.promise();<br>&nbsp; &nbsp; &nbsp; &nbsp; };
This topic has been closed for replies.

2 replies

Forum|alt.badge.img+13

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.


Forum|alt.badge.img+18
  • Author
  • July 11, 2024

Good to know! Thanks.