You need to sign in to do that
Don't have an account?
Jay reddy
Trigger to copy custom field at QuoteLineItem level to OpportunityLineItem's field
Hi,
New bee.
I need to copy a custom field [formula field] at QuoteLineItem level to custom field [currency] at OpportunityLineItem level.
I tried to write the below trigger. It saved but not displaying any results.
I need to copy Total price with Total discount & Var at quotelineitem level to "total price discount" at OpportunityLineItem level.
trigger TotalPriceDiscount on QuoteLineItem (after insert, after update) {
try {
List<OpportunityLineitem> OppItem = new List<OpportunityLineitem>();
Set<Id> ids = new Set<Id>();
for(QuoteLineItem qItem: Trigger.new) {
if(qItem.Product2 != null) {
Ids.add(qItem.Product2Id);
}
}
Map<id, OpportunityLineItem> OppliMap = new Map<id, OpportunityLineItem>([Select id, Total_Price_Discount__c from OpportunityLineItem Where Id in :Ids]);
for(QuoteLineItem qli : Trigger.new) {
// for(OpportunityLineItem Oppli : Trigger.new) {
// QuoteLineItem qli = qliMap.get(Oppli.Product2Id);
OpportunityLineItem Oppli = OppliMap.get(qli.Product2Id);
Oppli.Total_Price_Discount__c = qli.Total_Price_with_Total_Discount_VAR__c;
OppItem.add(Oppli);
}
update OppItem;
}
catch(Exception e){
System.debug('ERROR: '+ e);
}
}
Note: there can be multiple quotelineitems and same number at opportunity products.
Appreciate quick help
Thanks,
G
New bee.
I need to copy a custom field [formula field] at QuoteLineItem level to custom field [currency] at OpportunityLineItem level.
I tried to write the below trigger. It saved but not displaying any results.
I need to copy Total price with Total discount & Var at quotelineitem level to "total price discount" at OpportunityLineItem level.
trigger TotalPriceDiscount on QuoteLineItem (after insert, after update) {
try {
List<OpportunityLineitem> OppItem = new List<OpportunityLineitem>();
Set<Id> ids = new Set<Id>();
for(QuoteLineItem qItem: Trigger.new) {
if(qItem.Product2 != null) {
Ids.add(qItem.Product2Id);
}
}
Map<id, OpportunityLineItem> OppliMap = new Map<id, OpportunityLineItem>([Select id, Total_Price_Discount__c from OpportunityLineItem Where Id in :Ids]);
for(QuoteLineItem qli : Trigger.new) {
// for(OpportunityLineItem Oppli : Trigger.new) {
// QuoteLineItem qli = qliMap.get(Oppli.Product2Id);
OpportunityLineItem Oppli = OppliMap.get(qli.Product2Id);
Oppli.Total_Price_Discount__c = qli.Total_Price_with_Total_Discount_VAR__c;
OppItem.add(Oppli);
}
update OppItem;
}
catch(Exception e){
System.debug('ERROR: '+ e);
}
}
Note: there can be multiple quotelineitems and same number at opportunity products.
Appreciate quick help
Thanks,
G
1) http://amitsalesforce.blogspot.in/2014/11/syncing-custom-fields-between-quotes.html
Let us know if that will help you
Thanks
Amit Chaudhary
Unfortunately NO.
Isn't there any simple code?
Thanks,
G
can you post the above que code, I am facing same issue plz
thanks
Akshay