Find Usages of SObject should not include profiles

Issue #824 new
Scott Posey created an issue


Find Usages gets swamped by thousands of occurrences in Profiles, rendering it useless. I really only care about classes, triggers, and workflows. This is particularly problematic in a mature Salesforce Org with a large number of profiles, because each profile will have an entry like this that I don't care about:


In Java I think Find Usages brings up a dialog where you can select whether or not to search comments etc. There may be two menu items--one for the dialog version and one for whatever the dialog is set up to show.

The same thing could happen here and allow you to select various things, and then remember the selection between invocations.

Comments (12)

  1. Scott Wells repo owner

    Well, Java does actually show XML-based usages as part of its default behavior, e.g.:


    This is critical for the rename refactoring to work properly. Otherwise references in other metadata types wouldn't be included and would become stale. This doesn't just include metadata XML files but also Visualforce/Lightning markup and even Lightning JavaScript via usages such as c:apexControllerMethodName.

    You should be able to use the various toggles on the find usages result window to determine how to organize the results to separate source files from metadata files for perusal.

    Do you have an example of find usages resulting in thousands of undesirable references? Not debating the problem you're having, but trying to understand it better so that a solution can be found that doesn't lose the important concept of referential integrity across all metadata.

  2. Scott Posey reporter

    I'm not renaming. I'm finding usages.

    There are over 1k profiles in our org (to which I have no hope of giving you access. With an NDA I might be able to do a screen schare) and I don't need to see them when I'm trying to find usages of a custom class.

  3. Scott Wells repo owner

    Understood, but the rename refactoring works based on the same injected references as find usages (and navigation, etc.). It's via those references that just about all of this stuff works.

    You're correct that find usages has the ability to toggle comment and string usages off and on, but those are a first-class part of the plugin SDK. I'd have to see whether it's possible to extend those core capabilities more broadly to include/exclude certain types of references selectively for various operations so that it's not an all-or-nothing proposition in which case the rename refactoring, unused declaration code inspection, etc., would miss critical relationships.

  4. Scott Posey reporter

    Thanks for the detailed responses.

    For now, I'm able to work around it by doing directory-restricted text searches.

  5. Scott Wells repo owner

    Well, I definitely don't want you having to resort back to old school search! I'll take a look at what options I can provide once I knock out a few other items including the performance issue. I'll keep you posted on how it goes.

  6. Justin Julicher

    Find usages example.PNGHey scotttp666

    In settings --> Scopes you can create custom scope that would limit the find all results to just apex, lightning etc. You can do this by either including only the folders you want or excluding the folders like profiles and including everything else.

    In the find usages box you can then select the scope for find usages therefore excluding your profiles.

    This also works for Find in files.

    In the find usages box in the picture above click the settings button to open the dialog box for find usages settings. Then select your scope (or click the 3 dots to create a new one).

  7. Justin Julicher

    I think in Scotts reply the setting button is available too in the top right corner of the find usages drop down.

  8. Justin Julicher

    Hmmm although there seems to be a bug in Webstorm that it doens't update the scope once you've set it for the Find Usages code drop down.

    It definitely works for Find in path though ...

    IntelliJ - Find usages with scope works in the window (like in my example) but not on the drop down in code. I'll log a bug with jetbrains.

  9. Scott Posey reporter

    Thanks @justin_julicher I was able to configure the scope; however it seems that my IJ is configured not to display the dialog for Find Usages, which is why I couldn't configure the scope in the first place. Also puzzling is that it seems to have applied the scope globally with no way of modulating it per-command. But thanks that gets me out of the woods for now.

  10. Scott Wells repo owner

    Scott, how are you initiating Find Usages? In order to force the dialog you generally have to do Find Usages Settings which is Ctrl+Alt+Shift+F7 on Windows/Linux and (I believe) Cmd+Opt+Shift+F7 on Mac.

  11. Scott Posey reporter

    I'm using the right-click context menu. There used to be two options on that menu--one was 'Find Usages...' that brought up the version with the selections.

  12. Scott Wells repo owner

    Gotcha. I see the same thing from the context menu. I always do it from shortcut keys so I don't know what was in the context menu and when it might have changed. You're correct that the remaining entry just runs a Find Usages and shows the results in a docked panel. Here's how I typically use the Find Usages feature depending on what problem I'm trying to solve:

    • Quick navigation to a specific usage - Show Usages (Ctrl+Alt+F7)
    • Review standard usages - Find Usages (Alt+F7)
    • Quick navigation to usages in the same file - Highlight Usages in File (Ctrl+Shift+F7) or Find Usages in File (Ctrl+F7) ... (I almost always use the former)
    • Find usages in a specific scope - Find Usages Settings (Ctrl+Alt+Shift+F7)

    I would say that I use the first 90+% of the time, and you can even click the pin in the resulting pop-up to dock it just as if you'd used the second if you need it to hang around for reference.

    You should be able to customize the context menu to restore Find Usages Settings if you want. The menu bars, context menus, and toolbars are quite customizable in IntelliJ IDEA.

    I hope that helps in some form...

  13. Log in to comment