0

All,

Quick question!

A custom Order object and Order lines are generated via a trigger from the Opportunity and Opportunity Products.

  • Opportunity and Order have lookup relations between each other.
  • Opportunity Product has a lookup relationship to the Order Line object.
  • Order Line object does not have a lookup to the Opportunity Product. When I try to go to the Order Line, click new Lookup field the drop down does not list Opportunity Product/Line item option.
  • Order Line object has the Opportunity Product's SFID stored in a text field.
  • There is no parent-child relationship between Opportunity and Order .... and no parent-child between Opportunity Product and Order Line.

Ask is to use the above conditions to get Opportunity Product's fields on the Order Line object.(It can be formula field or text field on the Order Line level - Field Type does not matter) How can it be achieved?

Peace & Love

  • Is the record Id stored in a relationship field or in a text field? – David Reed Aug 8 at 18:06
  • @DavidReed: Text field. – Steve Aug 8 at 18:12
  • @DavidReed: What do you think? Is it posisble? Or do I need to write a custom trigger? – Steve Aug 8 at 18:28
0

Opportunity Product cannot be the target of a lookup field.

As a result, you cannot follow the natural solution, which would be to create a lookup from Order Product to Opportunity Product. Instead, since you do have the Salesforce Id of the corresponding Opportunity Product populated on the Order Product, you'll have to use automation to copy the fields that are of interest to you.

That automation may be either a Process Builder launching a Flow to query the related record, or an Apex trigger. Either will work fine.

If you need to sync the data when the related Opportunity Product is updated (not just at the time the Order Product is created), you'd need to create a second Apex trigger or Process + Flow to propagate those updates.

N.b.: it really helps if you ask your question in a specific way rather than using placeholders, since there are inherent platform restrictions in play here.

  • Thanks for the explanation. Originating Automation is not in my control - custom package. But there is no relationship between A.A and B.B. And I cannot choose a lookup field of object A.A when trying to create a lookup field from B.B. P.S. If I try the same from B, i.e. create a lookup, then I can find the related object A. – Steve Aug 8 at 18:46
  • P.S.> I have B.B lookup field populated in A.A object. Can I use that in any way? – Steve Aug 8 at 20:30
  • @Steve Could you please edit your post to be clearer about the data model? – David Reed Aug 8 at 20:31
  • Please let me know if this version is clearer – Steve Aug 8 at 20:55

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.