function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Integration 39Integration 39 

Send email from opportunity with product data

Hello,
I am trying to create an email template with data from the product accociated to the opportunity.

When i use the product varabiles i get null data returned.

I updated a trigger to write to the opportunity line item to grab the information i needed but that is also null.

It is not possible to get a trigger to update the opportunity as it is locked when triggered.

Does anyone have any suggestions to get around this?
AB TestAB Test
Hi

YOUR APPROACH :
First of all In the email template, you are getting null as in the email template cross object data can not be accessed.
 FYR : https://help.salesforce.com/apex/HTViewSolution?id=000005093&language=en_US

So you have the option to add the fields required through a trigger which you have rightly chosen.
Based on your second problem it seems that the record can not be updated as it is locked So if you'd like to modify this records (or records), you will need to query anew, modify, then execute another DML statement

FYR :http://salesforce.stackexchange.com/questions/14950/exeception-on-after-insert-record-is-read-only

NEW APPROACH :
But if you want to create email template on Opportunity and you are trying to replicate the data from line item to Opportunity (both on line item and opportunity) it would be a data duplication. You can try with Visual force email templates and check if it suffices your requirement. 

Hope this solves your problem.