You need to sign in to do that
Don't have an account?
Bhawna
MALFORMED_QUERY: SOQL statements can't query related data
Hi,
I'm facing the error message 'MALFORMED_QUERY: SOQL statements can't query related data'
thrown by this query
"SELECT Id, Name, (SELECT Quantity, ListPrice, PricebookEntry.UnitPrice, PricebookEntry.Name FROM OpportunityLineItems) FROM Opportunity o where o.Id='"+{!Opportunity.Id}+"'";
Since this gives the result on the Eclipse, force.com.
Any guidenance will be appreciated..
thanks,
OpportunityLineItem does not have a Child Relationship with PricebookEntries. It merely has an Pricebook Entry Id.
I suggest using the Eclipse schema viewer / query tool to help you build complex queries.
Best, Steve.
Hi Steve,
I tried to form different queries on OpportunityLineItem using Eclipse, they all run properly with such relationship.
like :
"Select o.Id,o.Description, o.Discount__c, o.OpportunityId,o.TotalPrice, o.PricebookEntryId,o.PricebookEntry.Product2Id, o.PricebookEntry.UnitPrice, o.Quantity from OpportunityLineItem o where o.OpportunityId='"+{!Opportunity.Id}+"'"
but when I use this query in js like:
var queryOppline=sforce.connection.query("Select o.Id,o.Description, o.Discount__c, o.OpportunityId,o.TotalPrice, o.PricebookEntryId,o.PricebookEntry.Product2Id, o.PricebookEntry.UnitPrice, o.Quantity from OpportunityLineItem o where o.OpportunityId="+"'"+"{!Opportunity.Id}"+"'");
var Records=queryOppline.getArray('records');
It throws an error.
I searched in the forum also, we use such relatioship.
Similar ex. is given in the "sforce_API.pdf"
kindly, get me out from this situation.
with lot of thanks,
This query is different from the previous one... this one is valid and the select below runs fine for me:
Select o.UnitPrice, o.TotalPrice, o.Quantity, o.PricebookEntry.Product2Id, o.PricebookEntryId, o.OpportunityId, o.Id, o.Description From OpportunityLineItem o where o.OpportunityId='00630000002zTEJAA2'
Perhaps you're not building your strings correctly, it's difficult to tell.
You could write:
var q = "Select ..... from OpportunityLineItem o where o.OpportunityId='{!Opportunity.Id}' ";
alert(q); // If you want to see it.
var queryOppLine = sforce.connection.query(q);
You should also use the FireBug extension for s-control development.
Best, Steve (going to bed...)
Hi Simon,
I'm using the latest version of API i.e 15, I cross checked my code on below this version till 13 and faced the same error message.
Bhawna
Hi,
I have done it, by resolving the query into parts, means related list query is executed based on the Id of related field fetched in the main query.
Thanks a lot for sparing time. :smileyhappy: