I have several Workflow Rules + Field Updates in my
QuoteLineItem object. This is not working well, since there is too much logic in Field Updates and I do not have full control on execution order, so I'm starting to move some of that logic to triggers.
I'm struggling with one of them. My field update is supposed to update a
QuoteLineItem's field with a value obtained from its related
PricebookEntry.UnitPrice upon creation (workflow rule criteria is Evaluate the rule when a record is created). So, my first thought was to convert that to a before insert trigger.
However, I need that lookup related field, but I don't have that field on the
trigger.new records right away, but I also can't query it since those objects do not have an Id yet to use in the query (as in
[SELECT Id, PricebookEntry.UnitPrice FROM QuoteLineItem WHERE Id IN :trigger.new]).
So, how can I get access to that lookup related field? Or is there a better approach than this before insert trigger to do what I want to?