+ Start a Discussion
emillar_altiaemillar_altia 

Trigger to get custom date field from Product Line Items into Quote line items custom date field.

I have created three custom fields for my product line items - 'StartDate', 'Duration' and 'EndDate'. The Start Date and EndDate are pretty self explanatory but the Duration field calculates the end date by the number of months added to the start date. I have created a new quote process where I am looking to send multiple quotes in one email to one customer. This process has been successful to a point, my problem is that when I create a quote, the information in my custom fields 'Start Date', 'Duration' and 'End Date' are not taken from the Product Line Items in the opportunity over into the Quote Line Items. I have been looking at apex code and have a tiny bit of experience with Java to create a trigger to do this, below is what I have started but I really don't think I'm going in the right direction as I'm looking at too many examples. Does anyone have a spare moment to point me in the right direction? 

 

trigger AutopopulateStartDate on QuoteLineItems (after insert, after update) {

 

//. Create a container for the products that need start dates inserted to them

 

Set <QuoteLineItems> updatedStartDate = new <QuoteLineItems> 


//If this is an insert, I want the date to be inserted to the correct product

 

if (trigger.isInsert) {

 

for (StartDate s : trigger.new) {

 

productstartdate.add;