I was trying to run a test using the QueryBuilder code examples with cross object fields in the where clause.
I was trying a simple query on pricebookentry:
select Id, UnitPrice, Pricebook2.Id, Product2.isActive from PricebookEntry where Pricebook2Id =: id AND Product2.IsActive = true
String query = new QueryBuilder(PricebookEntry.SObjectType)
.selectFields(new SObjectField[] {
PricebookEntry.Id,
UnitPrice
})
.selectRelatedField(Pricebook2.SObjectType, Pricebook2.Id)
.selectRelatedField(Product2.SObjectType, Product2.isActive)
.whereClause(new QueryCondition()
.isTrue(Product2.isActive))
.toString();
The output does not reference the Product or the Pricebook fields in the where clause. How would you reference cross object fields in the the where clause? The cross object fields are included in the select portion of the output, but not in the where clause. The pricebook.Id field is not included in the example above.