0

I'm working on building a tool in Salesforce that allows me to compare two profiles. As part of this tool, I need to programmatically list all profiles in Salesforce along with their permissions. After conducting some research, I came across the Tooling API, which seems to be the appropriate approach.

I would like guidance on how to get started with using the Tooling API to retrieve a list of all profiles and their permissions. Specifically, I plan to use Lightning Web Components (LWC) for the user interface and Apex for the backend logic.

Any help or guidance on the steps involved, sample code snippets, or any relevant resources would be greatly appreciated. I'm eager to start building this tool, so any assistance to kickstart the development process would be invaluable.

1 Answer 1

2

Apex Code exposes PermissionSet, SetupEntityAccess, FieldPermissions, and ObjectPermissions, so you can directly query these objects as if they were normal sObject entities. In other words, you don't need to use the Tooling API at all. Just query the appropriate objects and return those to your LWC, and you can display the values you're looking for.

In the future, salesforce.com plans on retiring/downgrading Profiles to only the parts necessary. As a part of that plan, the PermissionSet object serves two purposes: it can be a PermissionSet or a Profile. You can tell a PermissionSet is really a Profile by checking if IsOwnedByProfile is checked/true. The associated Profile Id will be located in the ParentId field, and you can use the Parent relationship to get Profile data (e.g. Profile.Name).

By using PermissionSet instead of Profile directly, you'll ensure that your code is future compatible with salesforce.com's plan to get rid of profiles. In addition, you may find that the ability to modify PermissionSet a useful feature for your app, given that this path forward is already in motion.

4
  • Can you explain how this relates to the Profiles, as requested in the question, rather than just PermissionSets? The FieldPermissions, for example, link to a parent (via ParentId) that is a Permission Set. (Not saying permissions should be managed in Profiles, but that's what the OP asks about.)
    – Phil W
    Commented May 11, 2023 at 13:18
  • Thanks @sfdcfox. I have the same question as that of Phil. Why do I need the starting point as permission set while I only need to extract the profile permissions. Appreciate if you could provide an example. Commented May 11, 2023 at 14:06
  • 1
    @Krishnamurthy Profiles are slowly being dismantled. PermissionSet is the way of the future. You can query for a Profile's Permission Set by using the ParentId field on PermissionSet. I've edited this answer to reflect that.
    – sfdcfox
    Commented May 11, 2023 at 14:51
  • Thank you for a detailed answer @sfdcfox Commented May 11, 2023 at 14:52

You must log in to answer this question.

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