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
Dhananjaya BulugahamulleDhananjaya Bulugahamulle 

How do redirect to a new page If check boxed is checked?

User-added image
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;
}



 
Best Answer chosen by Dhananjaya Bulugahamulle
William TranWilliam Tran
Here's the gist of it.

You can clean it up if you want (like take pagereference declaration outside of if) but not needed.

thx.
public PageReference next() {
    if(controller.save() == null) {
    return null;}


if(Product_Brief__c.Bioprocess_Container_Customization_Reqd__c) {  //or whatever variable represent your checkbox
PageReference ref = Page.pagebpc;
    ref.getParameters().put('id', controller.getId());
    ref.setRedirect(true);
    return ref;}
}
else{
    PageReference ref = Page.gibcopb2;
    ref.getParameters().put('id', controller.getId());
    ref.setRedirect(true);
    return ref;}

}