0

I want to run a query on the 'PermissionSetAssignment' object but I want get the name of the permission set and user instead of their ids.

SELECT IsActive, Id, PermissionSetId.Name, PermissionSetGroupId.Name, AssigneeId.Name FROM PermissionSetAssignment

I wrote the query above but it is throwing error. I also tried AssignedId__r.Name but it did not work.

Didn't understand relationship 'AssigneeId' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
1
  • 2
    As an aside, you should revisit your previous questions and accept answers that you've gotten if they were helpful. It's not required, but it does give both you and the person who gave the answer some reputation points and signals to the community that you don't need additional help with that issue. Also, you should probably take the tour and read How to Ask so that you become more familiar with how this site (and other stackexchange sites) operate.
    – Derek F
    Commented Feb 21 at 13:09

1 Answer 1

3

When querying for related data, you need to drop the Id part of standard relationships or change the __c to __r for a custom relationship field (master-detail or lookup).

So you need to use PermissionSet.Name instead of PermissionSetId.Name (and make similar adjustments for the other 2 related data fields you're querying for).

Also, using your search engine of choice to search for "salesforce [object name here] reference" is a handy way to confirm what fields are available (especially for things that are more of "system" objects that we can't get to from the Object Manager). As sfdcfox pointed out, PermissionSetGroup doesn't have a Name field. The object reference says that it does have DeveloperName. MasterLabel is another option.

3
  • 1
    PermissionSetGroup doesn't have a Name, though, it'll be DeveloperName instead.
    – sfdcfox
    Commented Feb 21 at 13:14
  • 1
    @sfdcfox answer appended.
    – Derek F
    Commented Feb 21 at 13:24
  • The Developer Console also shows the available fields. File | Open Resource | ObjectName.obj (e.g. Account.obj shows account fields).
    – sfdcfox
    Commented Feb 21 at 13:46

You must log in to answer this question.

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