I have created a button on Quote object to generate PDF and need to implement the below when the Approval Notice Field met the condition : Approval Notice = null. No error message and will generate PDF Approval Notice = not null. Error message and does not generate PDF



var c = new sforce.SObject("Quote"); 
c.id = "{!Quote.Id}"; 
var status = "{!Quote__c.Approval_Notice__c}"; 
if(status = ' ') 
window.location = 'apex/QuotePDFCallerPage?id='+c.id; 
alert('Quote has not been approved can not generate PDF');

Please let me know if i am doing it correctly or not


You have logic bugs and a lot of extra fluff in your code. You simply need to do this:

if({!ISBLANK(Quote__c.Approval_Notice__c)}) {
    window.location = "/apex/QuotePDFCallerPage?id={!Quote__c.Id}";
} else {
    alert("Quote has not been approved yet, so you cannot generate the PDF.")

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.