0

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.

1
  • looking through the code of this repo, the examples, and the test methods; I'm not sure it supports related objects as WHERE conditions, only fields on the target (PricebookEntry) object. If you don't get an answer here; post an Issue on the repo
    – cropredy
    Mar 17 at 22:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.