My question is about VisualForce page availability in Custom Tabs. I have a VisualForce page inside my managed package and I'd like to know if there is a way to prevent adding my pages to Custom Tab after installation of my package. I mean I'd like to force administrators/uses on customer's environment to not create a Custom Tab with my pages. Is this possible?

  • I just have to ask: why? – sfdcfox Jul 2 '14 at 0:42

A Visualforce tab generates an URL similar to this:


(you'll have your namespace in the domain but whatever)

So I guess you could try checking for presence of this parameter:

  1. In controller - with ApexPages.currentPage.getParameters()
  2. In VF - with {!$CurrentPage.parameters} (I guess it'd have to be {!$CurrentPage.parameters['sfdc.tabname']} because of the dot?)
  3. In Javascript - by inspecting location.href for example.

Now, as a client-side SF developer who has seen his share of crappy Appexchange apps and had to write some workarounds I'd get pi...retty angry.

I'd embed you in an <iframe> or "reuse" you with <apex:include> so I wouldn't call these bulletproof solutions. If you'll start detecting and blocking iframes your page will cease to work embedded in page layouts or within classic & service cloud console; as for "apex:include" - no idea if injected page sees the original top url.

  • 2. {!$CurrentPage.parameters.sfdc.tabname} works, tested this :) – Rao May 2 '14 at 20:53
  • 1
    Don't encourage him ;) – eyescream May 2 '14 at 20:55
  • lol, does the tab id remain same when creating a tab in an external org !!! may be a silly one, I do not have much experience with apps – Rao May 2 '14 at 20:56
  • Nope. It follows same rules as new custom objects (first one gets key prefix "a00", next one "a01" and so on), new custom fields, new anything. You'd have to install that package in orgs that had exactly same history to hope identical Ids will be generated ;) Same as making new field or report in sandbox and pushing to production - Id will most likely be different and will sync "down" when you'll eventually refresh that sandbox. – eyescream May 2 '14 at 21:00

I can't think of a way to prevent that without doing some sort of scheduled code run that made a describe call or checked the mdAPI to look at all the tabs and to do something like cripple your app if the tab with the page was created.

So yeah, I guess there is a way - but is it worth the hassle? Up to you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.