<script>
Array.prototype.contains = function (element)
{
for (var i = 0; i < this.length; i++)
{
if (this[i] == element)
{
return true;
}
}
return false;
};
var uniqueArr = new Array();
var result = sforce.connection.query("SELECT OwnerId from Account");
var record = result.getArray("record");
for(var i = 0; i < record.length;i++) {
if(!uniqueArr.contains(record[i].OwnerId)) {
uniqueArr.add(record[i].OwnerId);
}
}
</script>
Thank u very much dear, now i am able to solve my problem. but in java script array we can't add a element using add(); so i need to define another prototype for adding the element in array.
Code:
Array.prototype.add = function (element){ this[this.length] = element; };
You will have to carry out this in code
but i need to do it in S-Control, how could i do it.
//Now unique Arr contains all unique ownerIDs.
Thank u very much dear, now i am able to solve my problem.
but in java script array we can't add a element using add();
so i need to define another prototype for adding the element in array.
You can write aggreerate querry for this. Below is the link
lIST<AggregateResult> listofAccountsAggregateResult =
[SELECT Ownerid
FROM Account
GROUP BY Ownerid];
http://salesforceworld4u.blogspot.in/2013/12/fetching-unique-record-in-salesforce.html