You need to sign in to do that
Don't have an account?
Vanitha 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.
<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.
Open a new URL in the Subtab will support only console apps(Ex: Service console, Sales Console). For redirecting to the new page, we have multiple ways to achieve it.
https://salesforce.stackexchange.com/questions/91745/how-to-redirect-to-a-page-on-click-in-commandbutton
https://salesforce.stackexchange.com/questions/92288/oncomplete-javascript-to-pop-up-alert-and-redirect-to-a-record-page
https://developer.salesforce.com/forums/?id=906F000000097VKIAY
https://developer.salesforce.com/forums/?id=9060G000000Xg6WQAS
https://developer.salesforce.com/forums/?id=906F000000099SmIAI
https://salesforce.stackexchange.com/questions/117390/visualforce-page-redirect-not-working-from-apex-actionfunction
Regards
Vijay