1

enter image description here

I want to redirect to a new page (pagebpc) when user hit Save and Review button if above check box is checked. Otherwise it should goes to view page as it is on the extension. How do you add code for if it is checked, redirect to new and, If it is not, just the way it is. Thanks

input field for check box

 <apex:inputField value="{!Product_Brief__c.Bioprocess_Container_Customization_Reqd__c}" />

Save Button

 <apex:commandButton value="Save & Review" action="{!next}"/>

Extension

 public PageReference next() {
    if(controller.save() == null) {
    return null;}
    PageReference ref = Page.gibcopb2;
    ref.getParameters().put('id', controller.getId());
    ref.setRedirect(true);
    return ref;
}
2

Assuming controller is a reference to the StandardController:

public PageReference next() {
    if (controller.save() == null) {
        return null;
    }
    Product_Brief__c pb = (Product_Brief__c) controller.getRecord();
    if (pb.Bioprocess_Container_Customization_Reqd__c) {
        PageReference ref = Page.bpc;
        // Add any parameters required here
        return ref;
    } else {
        PageReference ref = Page.gibcopb2;
        ref.getParameters().put('id', controller.getId());
        ref.setRedirect(true);
        return ref;
    }
}
| improve this answer | |
  • thank you very much, it works exactly the way I want it. – Suneth Aug 14 '15 at 20:38

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.