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
Vanitha ManiVanitha Mani 

open in subtab

Hi i have command button when clicked its overriding the page instead i need to open it in its own subtab or new tab in lightning.

<apex:commandButton value="Clone Package To Selected CRs" action="{!clonePackageToChangeRequests}" reRender="pbId" status="fetchStatus" rendered="{!NOT(isCompleted)}"/>

Controller:
public PageReference clonePackageToChangeRequests() {
        Savepoint sp = Database.setSavepoint();
        try {
            Set<ID> crIds = new Set<ID>();
            for (SelectableChangeRequest record : changeRequests) {
            if(record.selected && record.obj.Customer_Packages__r.size() > 0) { //TKT-1239114
                 
                
              throw new CloneChangeRequestException(EXCEPTION_NAME);
            }else if (record.selected) {
                   crIds.add(record.obj.Id);
                    
                }
            }

            if (crIds.size() > 0) {
                return handleSuccess(SVC_CR_Package_Service.clonePackage(crIds, crPackage.Id));
            }
        } catch (Exception e) {
            Database.rollback(sp);
            ApexPages.addMessage(SVC_ErrorHandler.logAndConvertToApexMessage(e));
        }

        return null;
    }

 private PageReference redirect(ID recordId) {
        PageReference retURL = new PageReference('/' + recordId);
        retURL.setRedirect(true);
        return retURL;
 
           }
I read more articles on this but i couldnt find the  solution since there is a condition that if the package is present it should throw exception and if not it clones the package and should open that package in new subtab..Can anyone help me with this code.