无法从关系查询中引用用户名

问题描述

我正在尝试使用此查询为 Salesforce 中的测试用户获取 permissionSetGroupComponents。

SELECT AssigneeId,IsActive,ExpirationDate,PermissionSetGroupId,PermissionSetId FROM PermissionSetAssignment WHERE User.FirstName = 'Test'

但是当我运行时出现此错误

PermissionSetAssignment WHERE User.FirstName = 'Test'
                          ^
ERROR at Row:1:Column:119
Didn't understand relationship 'User' 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.

根据 API 文档,两个对象之间存在关系,所以我不明白为什么它找不到关系。 https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_permissionsetassignment.htm

解决方法

User 不是关系的名称。关系字段为 AssigneeId,因此关系字段为 Assignee

SELECT AssigneeId,IsActive,ExpirationDate,PermissionSetGroupId,PermissionSetId 
FROM PermissionSetAssignment 
WHERE Assignee.FirstName = 'Test'