+ Start a Discussion
SreejbSreejb 

A problem with the onclick javascript encountered unexpected number

Hi All

While creating a record from Candidate object to emplyee object using custom button on click on javascript behavior. I got the following error.

A problem with the onclick javascript encountered unexpected number.

Code is here

{!REQUIRESCRIPT('/soap/ajax/36.0/connection.js')}

 
var emp = new sforce.SObject('Employee__c');

 emp.Employee_First_Name__c =  {!Candidate__c.First_Name__c};
emp.Employee_Last_Name__c = {!Candidate__c.Last_Name__c};
emp.Mobile_No__c = {!Candidate__c.Mobile_No__c};
emp.Personal_Email__c = {!Candidate__c.Email__c};
emp.Employee_Address1__c = {!Candidate__c.Address1__c};
emp.Employee_Address2__c = {!Candidate__c.Address2__c};
emp.City__c = {!Candidate__c.City__c};
emp.State__c = {!Candidate__c.State__c};
emp.Zip_Postal_Code__c = {!Candidate__c.Zip_Postal_Code__c};


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

 
if(result[0].success == 'true')
{
    alert('A New Employee with Name - ' + emp.Eismployee_First_Name__c + ' was Created Successfully.');
}

Any one help on this... I am very new to salesforce and javascript... pls help on this


 
Best Answer chosen by Sreejb
Abhishek_DEOAbhishek_DEO
One thing I noticed that values should be enclosed in double quote. for eg.

"{!Candidate__c.First_Name__c}" please place them in double quote and see if it is working. 

All Answers

Abhishek_DEOAbhishek_DEO
One thing I noticed that values should be enclosed in double quote. for eg.

"{!Candidate__c.First_Name__c}" please place them in double quote and see if it is working. 
This was selected as the best answer
SreejbSreejb
Hi Abhishek,

I put single quotes '{!Candidate__c.First_Name__c}'..... Its working fine. Thanks a lot for your response.

Best Regards
Sreejayabalajee