+ Start a Discussion

Email Question: How to sort Javascript Object Array for sending single Email to Account Owner?


Can anyone please suggest a better way to do this:

We have an Object in javascript(in S-control) that stores the following details related to an email: email Accountowner and email_content. But we need to send only one email per Accountowner with all the contents for that owner. To do this I need to sort this object array by Account Owner. How can we sort such an Object Array by Account Owner:

The sample email object is as shown below:

emailObj= new Object();

The above object will be populated for all rows in the report that may/maynot have multiple records for the same AccountOwner. So the basic question is: in order to sent a single email to the Account Owner with all his related contents, how can we sort this Object Array? Also is there any other way to acheive this as I cannot sort the report by AccountOwner name due to some other constraints?

Appreciate all your feedbacks on this.

Use the array sort function built into Javascript.  Here is a link to the docs: http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:sort