+ 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)}"/>

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) {

            if (crIds.size() > 0) {
                return handleSuccess(SVC_CR_Package_Service.clonePackage(crIds, crPackage.Id));
        } catch (Exception e) {

        return null;

 private PageReference redirect(ID recordId) {
        PageReference retURL = new PageReference('/' + recordId);
        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.