I'm setting an an AEP Selector which needs to implement the following:
[select ParentId from SetupEntityAccess where SetupEntityId in
(select Id from CustomPermission where DeveloperName = :name)]
However, I'm struggling to wrap my head around how this could be done with out performing two separate queries.
Does anyone know how to do this with out executing a query first to get the Ids
of CustomPermission
, then performing another query passing the Ids in?
Here's the selector class missing the implementation for this query:
public inherited sharing class SetupEntityAccessesSelector extends fflib_SObjectSelector implements ISetupEntityAccessesSelector
{
public static ISetupEntityAccessesSelector newInstance()
{
return (ISetupEntityAccessesSelector) Application.Selector.newInstance(SetupEntityAccess.SObjectType);
}
public List<Schema.SObjectField> getSObjectFieldList()
{
return new List<Schema.SObjectField> {
SetupEntityAccess.Id,
SetupEntityAccess.ParentId
};
}
public Schema.SObjectType getSObjectType()
{
return SetupEntityAccess.SObjectType;
}
public List<SetupEntityAccess> selectByCustomPermission(String name)
{
fflib_QueryFactory setupEntityAccessQueryFactory = newQueryFactory();
// Somehow do this:
// [select ParentId from SetupEntityAccess where SetupEntityId in (select Id from CustomPermission where DeveloperName = :name)]
return Database.query(setupEntityAccessQueryFactory.toSOQL());
}
}
Thank you.
in (soql query)
in these examples. Am I somehow overlooking it?