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
oceanofstarsoceanofstars 

Need to stop generating purposal if the condition is False...but i am able to generate the proposal

public PageReference genProposa () {
        PageReference proposalPage = new PageReference('/apex/buildContractnew?Id=' + quote.Id);
        proposalPage.setRedirect(true);
        return proposalPage;

}

 

Hi I modify the above code to the below in order to stop creating proposal if the below condition is not satisfied. I am able to save the code but i can generate the proposal even if the below condition is not true. Can you please let me know where did i make the mistake. SSOW_product_Formula__c fields are null. Even if they are null i am able to generate a proposal. Actually it needs me to throw the error('test test test') if i click the generate proposal button

 

public PageReference genProposal() {
    PageReference proposalPage= new PageReference('/apex/buildProposal?Id=' + quote.Id);
    List<QuoteLine__c> q = [SELECT Id from QuoteLine__c WHERE Quote__c = :quote.Id AND SSOW_Product_Formula__c != ''];
    List <SSOW__c> sow = [Select Id From SSOW__c WHERE Quote__c = :Quote.Id AND Sales_Proposal_Fields_Complete__c = 'Yes'];
    If (sow.size()>0 && q.size()>0){
        
        proposalPage.setRedirect(true);
        }
    else{
        QuoteErrorMessages.add('test test test');
        }
        return proposalPage;
    }