Skip to main content
Nintex Community Menu Bar

Is there a “MODEL_LOOKUP” like function usable in Javascript snippets? I’m looking to, in javascript, be able to get a specific row from a model based on a key (eg. the Salesforce ID of the row).

I’m finding myself needing to go through loops to construct Maps in Javascript in order to have this functionality, but if there is some way I can pull a row from a model based on a key (like the MODEL_LOOKUP function but in Javascript) I wouldn’t need to do that.

Is there a similar function to MODEL_LOOKUP usable in Javascript that will return the row (or values from the row) I’m looking for based on a key? I’m not finding a function like this in the model methods documentation.

Thanks!

I see this function that could work:


getRowById(id)

Returns the row in this model identified by the given Id.

Arguments:
  • id (string) – The Id of the row. Typically an 18-character Salesforce Id, though may also be a Skuid Unique Id for newly created rows that have not been added to the database yet.
Returns:

A row object

Return type:

object

----------------------


But what if I didn’t want to use the Salesforce ID of the row, but rather a different key on the row? For instance if I’m using an aggregate model and am grouping by a related lookup item ID rather than the actual SFID of the object being queried. Is there some way to pull based on a specific field (similar to MODEL_LOOKUP)


Hi Mark, we were wondering if you could find a solution in the meantime? Here is an example page with a snippet that we think might be helpful for you. You would need to modify the accountName to match the field alias you want to check, as well as the actual content. “TestAccount” is the name of an account in the org where we built the page.




























































var params = argumentse0],
$ = skuid.$,
model=skuid.$M("Opps");
var info = model.data.filter(function(row){return row.accountName === "TestAccount"});
console.log(info)








In case you haven’t seen it yet, this online documentation about dataConditions for getRows might be interesting, too.

We hope this information are helpful for you.


Reply