Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

newbie to javascript help please

Status
Not open for further replies.

zishan876

Programmer
Mar 19, 2007
61
US
Hi:
This is my code:
Code:
z_cal.prototype.submitSelections = function () 
//PRIVATE: submit the calendar's selection variables 
{ 
var dtsdate = new sforce.SObject("Holiday_Vacation__c");
//alert(this.selectedDates[0].toJSDate() + "-" + dtsdate.Opportunity__c);
for(var i=0; i<this.selectedDates.length; i++) 
dtsdate.Date__c = this.selectedDates[i].toJSDate();
dtsdate.Opportunity__c = "{!Opportunity.Id}";
	
  
var result = sforce.connection.create([dtsdate]);

  if (result[0].getBoolean("success")) {
    alert("new account created with id/Date " + result[0]);
  } else {
   alert("failed to create account " + result[0]);
  }
};

I am not getting an error with this . The issue is from the date array it is inserting the last date and nothing else with the opportunity ID. It looks like it goes through the loop of the array but ends up placing just the last record of the array into my table. So I am lost on how to get the entire array in with the id.

like if they select 3/2/2007, 3/3/2007,3/4/2007 with the opportunity id 11111. It will place in 3/4/2007 and 11111.

it will not place in the other dates...
Any help would be appreciated thanks
Z

 
I figured it out it was within my for loop
Code:
z_cal.prototype.submitSelections = function () 
//PRIVATE: submit the calendar's selection variables 
{ 
var dtsdate = new sforce.SObject("Holiday_Vacation__c");
//alert(this.selectedDates[0].toJSDate() + "-" + dtsdate.Opportunity__c);
for(var i=0; i<this.selectedDates.length; i++) 
{
dtsdate.Date__c = this.selectedDates[i].toJSDate();
dtsdate.Opportunity__c = "{!Opportunity.Id}";
var result = sforce.connection.create([dtsdate]);
}
  if (result[0].getBoolean("success")) {
    alert("new account created with id/Date " + result[0]);
  } else {
   alert("failed to create account " + result[0]);
  }
};
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top