3

We are trying to clean up the tabs in a demo org (we've reached the limit of 100).

I've been looking for a Metadata or Schema API, preferably one I can use from Apex, that will let me query for a list of all Lightning tabs in the org and who created each of them.

So far, I've found:

  • Describing Tabs Using Schema Methods which appears to be limited to tabs that are part of an app (many of our tabs were created from the Lightning App Builder and are not yet part of an app) and

  • describeAllTabs() which promises to return "information about all the tabs—including Lightning page tabs", but which does not appear to include who created each tab.

I can find this information easily for a single tab in Setup:

enter image description here

But this doesn't scale well when you need to quickly contact all of the folks who've created these tabs and warn them about the oncoming purge.

2 Answers 2

5

Use the Tooling API to query CustomTab. In the Developer Console, go to the Query Editor, then write a query, and check the Tooling API box at the bottom of the tab. You can start with this query. Check the docs for more info.

Select CreatedDate, CreatedById, DeveloperName From CustomTab
7
  • This is the way to go, but there's an annoying limitation in that there's no field that can be used in queries that return more than one record that will tell you what object a tab with Type = customObject is for. You'll have to query for them individually with the Id, and include the FullName field in that query. Aug 7, 2019 at 19:55
  • Thanks. Exactly what I was looking for.
    – JDB
    Aug 8, 2019 at 16:14
  • @sfdcfox Hi! How should I format a tab name in the sfdx command, based on the tab label, I need to retrieve a specific tab that I've created in salesforce using the command in the terminal, I'm trying the following and it says No results found, sfdx force:source:retrieve -m CustomTab:Commerce_Buffer__c.tab-meta.xml Tab Label is: Commerce Buffres I need to retrieve this so I can commit to the repo, Thanks!
    – Bahman.A
    Jun 23, 2020 at 21:09
  • 1
    @Bahman.A I'm mobile right now, but the tab name should be the same as the object but without the double underscores by default. You can edit the tab in setup to see its API name.
    – sfdcfox
    Jun 23, 2020 at 21:16
  • 1
    @Bahman.A I answered it, too. Let me know how it goes.
    – sfdcfox
    Jun 23, 2020 at 21:20
3

As an alternative, perhaps you can take the following approach instead for communications and the purge.

  1. Compile a list of users who have recently logged in from the login history.
  2. Notify the potentially affected users that a cleanup is underway in the org.
  3. Back up all of the existing tabs, applications, profiles and permission sets in source control using the Salesforce CLI.
  4. Delete the tabs you don't want.
  5. Notify the potentially affected users that the cleanup is complete.

You can use the sfdx command below to pull down the tabs, tab positions within custom apps, along with tab visibilities assigned through permission sets and profiles.

sfdx force:source:retrieve -m CustomApplication:*,CustomTab:*,PermissionSet:*,Profile:*
1
  • It's a good suggestion. I was also hoping to get the Created Date so that I can focus on older tabs, but this is the approach we'll have to take if we can't get that metadata.
    – JDB
    Aug 7, 2019 at 17:57

You must log in to answer this question.

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