+ Start a Discussion
WikWik 

Bypassing a Validation Rule

Hi,

I have a Validation rule set up on Quote. I have overridden the Clone button on Quote with a Visual Force page.

How to induce a logic such that when the user clicks the "Clone" button, the validation rule is bypassed?

I have created a checkbox named "Isclone" but can not figure out how to provide conditions on this.

Thank You

Ramu_SFDCRamu_SFDC
Add a condition in the existing validation rule as "isclone__c=false" assuming that the visualforce page is setting the checkbox to true by default.
WikWik

yes i have added the condition you are talking about, am not getting the right direction as to
How to set the Checkbox to True using the VF Page or Apex?

My VF Page:

<apex:page standardController="Quote" extensions="CloneABUMQuote" action="{!autorun}">

   


    <apex:sectionHeader title="Auto-Running Apex Code"/>
    <apex:outputPanel >
        You tried calling Apex Code from a button.  If you see this page, something went wrong.  You should have been redirected back to the record you clicked the button from.
    </apex:outputPanel>
</apex:page>

 

Ramu_SFDCRamu_SFDC
See if this post is of any help

https://developer.salesforce.com/forums?id=906F000000090VdIAI
WikWik
My Controller:

Please guide me , do i need to make change only in the controller or vf too

here is my controller

private Quote Qte;
    public string QteId { get;set; }
     
    public CloneABUMQuote (ApexPages.StandardController stdController) {
        this.Qte = (Quote)stdController.getRecord();
        QteId = ApexPages.currentPage().getParameters().get('QteId');
        if(this.Qte != null && this.Qte.id != null)
            this.Qte = ABUMDAO.getQuote(stdController.getId());
           
        system.debug('QteId = ' + QteId);
    }

    public PageReference autorun() {
        if (this.Qte.Job_Type__c == ABUMCalculator.JOBTYPE_SA ||
                this.Qte.Job_Type__c == ABUMCalculator.JOBTYPE_BUR) {
            Quote newQte = SAPricingDAO.cloneQuoteAndChildren(this.Qte);
            PageReference pr = Page.QuoteEdit;
            pr.getParameters().put('Id', newQte.Id);
            pr.getParameters().put('isCloned', 'true');
            pr.setRedirect(true);      
            return pr;
        } else {
        

           
           PageReference QtePage = new PageReference('/apex/pages/ABUMEdit?id='+this.Qte.Id);
            QtePage.getParameters().put('isCloned', 'true');
            QtePage.setRedirect(true);
            return QtePage;
           
          
        }
    }
}