Usage :
var redirectURL = getRedirectURL(redirectPage,linkType);
var redirectTo_url = redirectTo('{!recordId}',redirectURL, openInSubtab, actionLabel, linkType );
function redirectTo(recordId,url,openAsSubtab, tabLabel, linkType){ | |
debugger; | |
if( sforce && sforce.one ){ | |
if ( linkType == 'Standard View'){////replace with variable | |
sforce.one.navigateToSObject(recordId, view); | |
} else if ( linkType == 'Standard Edit'){ | |
sforce.one.editRecord(recordId) ; | |
} else if ( linkType == 'Standard Delete'){ | |
sforce.one.navigateToURL(url,false); | |
} else { | |
sforce.one.navigateToURL(url,false); | |
} | |
} else if( sforce && sforce.console && sforce.console.isInConsole()) { | |
var data = {}; | |
data.url = url; | |
data.tabLabel = tabLabel; | |
openConsoleTab(data); | |
} else { | |
debugger; | |
if( openAsSubtab ){ | |
window.open( | |
url, | |
'_blank' // <- This is what makes it open in a new window. | |
); | |
} else { | |
if (inIframe()) { | |
window.top.location.href = url; | |
} else { | |
window.location.href = url; | |
} | |
} | |
} | |
} | |
function getRedirectURL(url, linkType){ | |
var recordId ='{!recordId}'; | |
if ( linkType == '{!VF_TYPE}' ) { | |
return '/apex/'+url+'?id='+recordId; | |
} else if ( linkType == '{!URL_TYPE}') {//replace with variable | |
return url+'?id='+recordId; | |
} else if ( linkType == '{!STANDARD_VIEW}'){////replace with variable | |
return '/'+recordId; | |
} else if ( linkType == '{!STANDARD_EDIT}'){ | |
return '/'+recordId+'/e'; | |
} else if ( linkType == '{!STANDARD_DEL}'){ | |
//todo | |
} | |
} |