function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
a88zacha88zach 

Getting Distinct fields using VB

Ok, so I see in the boards that the Distinct command does not exist i the SOQL query language and I see that there are other ways of doing this but I only see examples in c#.  Could someone please help me create a list of distinct values in vb.

 

I am curently trying to pull the values from salesforce, then create a list of unique values from the list returned by the query, and then populate a dropdown box with the unique values.  Any help would be great

 

-z

RichAintRichRichAintRich

I'm using the SuperCell application (Free eddition from AppExchange) to help put together my queries and SOQL. Instead of using the Distinct keyword, Salesforce spring edition now allows Group By. Per the SuperCell app, if I create a Summary query on one field, the AccountType field in the Account object for instance, the SOQL generated is:

 

SELECT Account.Type

FROM Account

GROUP BY Account.Type

 

The app will generate the SOQL used for the query and put it to the clipboard. You can then paste it into your project. Hope this helps.

AlwaysConfusedAlwaysConfused

 

Have a look at linq mate ... works in both vb and C# and the whole point in it is the concept of "Language Integrated Querying" so you can do stuff like this ...

 

sObject[] yourObjects = GetSomeObjectsFromSomewhere();

 

sObject[] distinctResults = yourObjects.Distinct( propertyName );

 

There's much more to it and it does depend on the situation but maybe you should consider starting somewhere like here ...

http://forums.asp.net/t/1220691.aspx

 

The beauty of this of course is that the syntax doesn't change between C# and VB :)