I am trying to create one custom button which works in both console app and normal salesforce tabs using onclick javascript.

I'm facing an issue 'Registry is null or undefined' in console app.

My code looks similar to this

var redirectUrl = '/{!Case.AccountId}';
if (sforce.console.isInConsole()) {
            sforce.console.openSubtab(primaryResult.id, redirectUrl, true, '', null);
else {
    window.location.href = redirectUrl;

If I add this line: {!REQUIRESCRIPT("/xdomain/xdomain.js")}, then the 'Registry is null or undefined' error doesn't appear but the tab is not opening.

Please help.

1 Answer 1


The redirect URL is different in and outside of the Console. Define the redirect URL as {! URLFOR($Action.Account.View, Case.AccountId) } or similar, depending on your context.

I hope that helps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .