0

I am trying to send an email (from Classic Email Template) on button click with validation and field update. But when I click the button, it does nothing.

Can you please help me what's wrong?

{!REQUIRESCRIPT("/soap/ajax/35.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/35.0/apex.js")} 

var c_email = '{!CustomObject__c.Email__c}'; 
var c_name = '{!CustomObject__c.Name}'; 
var personAccount = '{!CustomObject__c.Person_Account__c}'; 
var dateCompleted = '{!CustomObject__c.Completion_Date__c}'; 

if(c_email == '' || c_name == '' || personAccount == '' || dateCompleted == null) { 

alert('Please complete required fields before sending Form.'); 

} else { 

location.replace('/email/author/emailauthor.jsp?retURL=/{!CustomObject__c.Id}&p3_lkid={!CustomObject__c.Id}&rtype=003&p2_lkid={!CustomObject__c.Email__c}&template_id=00XN00000012cqH');

var cToUpdate = new sforce.SObject("CustomObject__c");

cToUpdate.Status__c = 'Form sent'; 
cToUpdate.Date_Form_Sent__c = new Date(); 
sforce.connection.update([cToUpdate]);

window.location.reload(); 
}
  • can you check if there are any errors on the console? – rahul gawale Jul 18 at 6:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.