Sean Hogan
Sean Hogan

Reputation: 89

Get Unique list of Projects in Store

Is it possible to query a unique list of Project values within an existing Store? Is seems like the Collect method works with string values, but the Project field is an object value.

Thanks!

Upvotes: 2

Views: 50

Answers (1)

Kyle Morse
Kyle Morse

Reputation: 8400

Have you used lodash yet? It's included in the SDK as a dependency and it's awesome for manipulating data. You can read more about it here:

https://help.rallydev.com/apps/2.0/doc/#!/guide/third_party_libs-section-lo-dash-2.4.1

Here we can use _.map and _.uniq to get the desired result:

var projectNames = _.map(store.getRange(), function(record) {
    return record.get('Project').Name; //or ref, or objectid, etc...
}),
    uniqueProjectNames = _.uniq(projectNames);

Upvotes: 2

Related Questions