3

I have attached a screenshot of the schema. I have order, order_lines and shipment_lines related as in the following picture... enter image description here

Is it mandatory to create a junction object to get shipment lines for a particular order line?

Thanks in advance!

  • I'm having trouble understanding why Shipment lines is related to Order if the Shipment is related to the order (grandparent). A Shipment line item would seem to be a junction between Shipment and Order Line Item. – greenstork Sep 8 '14 at 17:30
2

You can use the existing objects and relationships e.g. like this:

select Id, ...
from ShipmentLine__c
where Shipment__c in (select Shipment__c from OrderLines__c where Id = :orderLineId)
order by ...

so in general no you do not need to introduce another relationship/junction object.

Here is a good article on the subject of A Deeper look at SOQL and Relationship Queries on Force.com.

| improve this answer | |
  • This looks gr8! I wanted to have a field in ShipmentLines__c to display corresponding OrderLines__c. T think I will have to write a trigger to retrieve that field. Am I going the right direction? – MnZ Sep 8 '14 at 19:50
  • @MnZ Yeah if you are trying to have a direct link from a S hipmentLines__c to an OrderLines__c you'll need to put the logic in several triggers. – Keith C Sep 9 '14 at 8:03

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.