Using Javascript code .. how can i display all the sucess records???
Hi All,
I have a Javascript code to send email to the selected records... Now i simply want to to display all those records with their Employee code for which an Email has been sent sucessfully...Pls Help... below is my JS code:
var recordsSelected = {!GETRECORDIDS( $ObjectType.RMG_Employee_Master__c)};
if (recordsSelected.length < 1) { alert('Please select atleast one recrod'); } else if(confirm('Are you sure to send email to the selected records?')) { for (var j=0; j< recordsSelected.length; j++) {
var result = sforce.connection.query('select Email_Address__c, EmpCode__c,Name,Send_Email__c from RMG_Employee_Master__c where id = '+"'" +recordsSelected[j] + "'");
var employee = new sforce.SObject("RMG_Employee_Master__c"); employee.Id = recordsSelected[j]; employee.Send_Email__c = 'True'; result = sforce.connection.update([employee]);
employee.Send_Email__c = 'False'; result = sforce.connection.update([employee]);
// i have tried using this code to achieve the same.. but its giving me undefined........ var myarray=new Array(); myarray[j]=employee.EmpCode__c; alert(myarray[j]);
In your code you are creating a new array every time in the loop. You just
create array outside the loop and add the elements in the array inside the loop :
In your code you are creating a new array every time in the loop. You just
create array outside the loop and add the elements in the array inside the loop :
In your code you are creating a new array every time in the loop. You just create array outside the loop and add the elements in the array inside the loop :
var myarray = new Array();
for (var j=0; j< recordsSelected.length; j++)
{
myarray[j]=employee.EmpCode__c;
}
All Answers
This should do what you want, though if you send an email to 20 people in the List view, you would get 20 alert messgaes....
Hope this helps.
Jay
In your code you are creating a new array every time in the loop. You just create array outside the loop and add the elements in the array inside the loop :
var myarray = new Array();
for (var j=0; j< recordsSelected.length; j++)
{
myarray[j]=employee.EmpCode__c;
}