function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ramana VRamana V 

Javascropt Error

Hi All,
I am getting following error in javascript. Please help me with this error.
 
{!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")}   
 
var newRecords = [];   
 
var coapp = new sforce.SObject("Lead");  
coapp.id ="{!Lead.Id}"; 
coapp.Name="{!Lead.Name}" 
coapp.Rating="Hot";             
 
newRecords.push(coapp); 
result = sforce.connection.update(newRecords); 
window.location.reload();

Error: The Name field is required.

Thanks in Advance
Best Answer chosen by Ramana V
Soyab HussainSoyab Hussain
Hi Ramana,
I think you just need to add and semicolon after "{!Lead.Name}";
 
{!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")}   
 
var newRecords = [];   
 
var coapp = new sforce.SObject("Lead");  
coapp.id ="{!Lead.Id}"; 
coapp.Name="{!Lead.Name}";
coapp.Rating="Hot";             
 
newRecords.push(coapp); 
result = sforce.connection.update(newRecords); 
window.location.reload();



Regards,
Soyab

All Answers

Soyab HussainSoyab Hussain
Hi Ramana,
I think you just need to add and semicolon after "{!Lead.Name}";
 
{!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")}   
 
var newRecords = [];   
 
var coapp = new sforce.SObject("Lead");  
coapp.id ="{!Lead.Id}"; 
coapp.Name="{!Lead.Name}";
coapp.Rating="Hot";             
 
newRecords.push(coapp); 
result = sforce.connection.update(newRecords); 
window.location.reload();



Regards,
Soyab
This was selected as the best answer
Sanvee MeharaSanvee Mehara
Ya @Soyab Hussain, you are right. Only need to add and semicolon after "{!Lead.Name}";
Deepali KulshresthaDeepali Kulshrestha
Hi Ramana,


I went through your problem. you can't use all mandatory fields of Lead.

You can use the below code:-


 {!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")}   
        
        var newRecords = [];   
        
        var coapp = new sforce.SObject("Lead");  
        coapp.id ="{!Lead.Id}"; 
        coapp.LastName="{!Lead.LastName}";
        coapp.Company="{!Lead.Company}";
        coapp.status="{!Lead.status}";
        coapp.Rating="Hot";             
        
        newRecords.push(coapp); 
        result = sforce.connection.update(newRecords); 
        window.location.reload();


I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com