1

I've made a few attempts to pull an opportunity field (Bill_To_Account__c from line items. I came across this post but can't figure out the solution.

Attempt 1

SELECT Id, Forecast_Start_Date__c, Forecast_End_Date__c, Forecast_Product_Name__c, 
Name, OpportunityId, (SELECT Bill_To_Account__c FROM Opportunity)
FROM OpportunityLineItem

The error:

INVALID_TYPE:
(SELECT Bill_To_Account__c FROM Opportunity)
^

Attempt 2

SELECT Id, Forecast_Start_Date__c, Forecast_End_Date__c, Forecast_Product_Name__c, 
Name, OpportunityId, Opportunity__r.Bill_To_Account__c
FROM OpportunityLineItem

The error:

INVALID_FIELD:
Forecast_Product_Name__c, Name, OpportunityId, Opportunity__r.Bill_To_Account__c
^
2

Attempt 2 should work, but you should try Opportunity.Bill_To_Account__c instead of Opportunity__r.Bill_To_Account__c since it's not a custom relationship.

1
  • That did it! Thank you :)
    – Kermit
    Mar 1 at 20:40

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.