+ Start a Discussion
Mahesh G 15Mahesh G 15 

a problem with the onclick javascript for this button or link was encountered : Invalid time value in salesforce

{!REQUIRESCRIPT('/soap/ajax/27.0/connection.js')}
getDate = function(dte){
var day = dte.getDay() < 9 ? '0'+dte.getDay() : dte.getDay();
alert(day);
var month = dte.getMonth() < 9 ? '0'+dte.getMonth() : dte.getMonth();
alert(month);
alert(month+'/'+day+'/'+dte.getFullYear());
return month+'/'+day+'/'+dte.getFullYear();


}
 

 
var Vendor= new sforce.SObject('Vendor__c');
 
Vendor.Name = '{!Interview__c.First_Name__c} {!Interview__c.Last_Name__c}';
Vendor.Primary_Contact__c = '{!Interview__c.First_Name__c} - {!Interview__c.Last_Name__c}';
Vendor.Primary_Contact_Phone__c = '{!Interview__c.Phone_Number__c}';
Vendor.Phone__c = '{!Interview__c.Phone_Number__c}';
Vendor.Primary_Contact_Email__c = '{!Interview__c.Email__c}';
Vendor.Address__c = '{!Interview__c.Home_Address__c}';
Vendor.Emergency_Contact_Name__c = '{!Interview__c.Emergency_Contact_Name__c}';
Vendor.Emergency_Contact_Number__c     = '{!Interview__c.Emergency_Contact_Number__c}';
Vendor.Emergency_Contact_Relationship__c = '{!Interview__c.Emergency_Contact_Relation__c}';
Vendor.SS_or_Tax_ID__c = '{!Interview__c.Tax_ID__c}';
Vendor.Labor_Company__c = true;

var dte='{!Interview__c.Birthday_plus_1__c}';

var dat =new Date(dte).toISOString();

 
Vendor.DOB__c = dat;

Vendor.recordtypeid ='012G0000001YaqwIAC';


result = sforce.connection.create([Vendor]);

var c = new sforce.SObject("Interview__c");
c.id = "{!Interview__c.Id}";
c.Application_Status__c = 'Hired';
c.Vendor__c=result[0].id;
result1 = sforce.connection.update([c]);
document.location.reload(true)


 
if(result[0].success == 'true'){
    alert('An New Vendor with Name - ' + Vendor.Name + ' was Created Successfully.');
}
Prithviraj_ChavanPrithviraj_Chavan
Hi Mahesh,
you havent called getDate function..
Mahesh G 15Mahesh G 15
Can u please explain clearly