I want to make a custom relation between Opportunity
and Account
.
I want to retrieve the account who makes the opportunity
So I wrote this:
"SELECT Id, RecordType.Name, Name, Description, StageName, CloseDate, Type, IsClosed, IsWon,HasOpportunityLineItem, Pricebook2.Name , Owner.Sales_representative_code__c
, Owner.FirstName, Owner.LastName, Shipping_method__c, Payment_method_code__c, Payment_terms_code__c, Consumables__c, End_date__c, Start_date__c, Expected_delivery_date__c
, Pricing_model__c, Customer_insights__c,Shipping_cost_at_our_expense__c,
(
SELECT Customer_code__c,Name,Payment_method_code__c,Payment_terms_code__c, Blocked__c, VAT_Code__c, TIN__c
,Owner.Sales_representative_code__c, Owner.FirstName, Owner.LastName, Primary_contact__r.Contact_person_code__c
, Primary_contact__r.FirstName, Primary_contact__r.LastName
FROM Account
)
FROM Opportunity
WHERE Opportunity.IsClosed = true
AND Opportunity.IsWon = true
AND Opportunity.HasOpportunityLineItem = true
"
But I got this error in output:
Didn't understand relationship 'Account__r' in FROM part of query call. 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.'
What's wrong?
thanks in advance.