You need to sign in to do that
Don't have an account?

Update Price on Custom Object, when price on price book enteries changes ?
Hi,
I have written this apex class to update prices on Product Interest Line Item, when price on Price book enteries changes.. However, the new price is not reflcting.. Can someone please help
Also, I want the new price to come basis the pricebook selected on the Product Interest level.
So , If A pricebook has 20 , and B pricebook has 30 , and If selected pricebook is 20. I want to update the New price field with changes in Pricebook A.
,
Also, I need to understand is a batch required for this or it will work everytime a price gets changed. Reason of asking is , I need to send a mail, when price on Price book entry is lower than Product Interest line item
public class UpdateRecentPriceOnProductInterest {
public void updateList()
{ List<Product_Interest_Line_Item__c> pliobj;
a
pliobj=[select Id, name,Product_Code__c, New_Price__c,CSP_Edit__c from Product_Interest_Line_Item__c];
for(Product_Interest_Line_Item__c pli :pliobj)
{
Map<Id,PricebookEntry> mapPe=new Map<Id,PricebookEntry>([select id, UnitPrice from PricebookEntry and Productcode = : pli.Product_code__c]);
for(Id id : mapPe.keySet())
{
pli.New_Price__c=mapPe.get(pli.Product_code__c).unitprice;
}
}
update pliobj;
}
}
I have written this apex class to update prices on Product Interest Line Item, when price on Price book enteries changes.. However, the new price is not reflcting.. Can someone please help
Also, I want the new price to come basis the pricebook selected on the Product Interest level.
So , If A pricebook has 20 , and B pricebook has 30 , and If selected pricebook is 20. I want to update the New price field with changes in Pricebook A.
,
Also, I need to understand is a batch required for this or it will work everytime a price gets changed. Reason of asking is , I need to send a mail, when price on Price book entry is lower than Product Interest line item
public class UpdateRecentPriceOnProductInterest {
public void updateList()
{ List<Product_Interest_Line_Item__c> pliobj;
a
pliobj=[select Id, name,Product_Code__c, New_Price__c,CSP_Edit__c from Product_Interest_Line_Item__c];
for(Product_Interest_Line_Item__c pli :pliobj)
{
Map<Id,PricebookEntry> mapPe=new Map<Id,PricebookEntry>([select id, UnitPrice from PricebookEntry and Productcode = : pli.Product_code__c]);
for(Id id : mapPe.keySet())
{
pli.New_Price__c=mapPe.get(pli.Product_code__c).unitprice;
}
}
update pliobj;
}
}
public class UpdateRecentPriceOnProductInterest {
public void updateList()
{
List<Product_Interest_Line_Item__c> pliobj;
pliobj=[select Id, name,Product_Code__c,New_Price__c,CSP_Edit__c from Product_Interest_Line_Item__c];
list<Product_Interest_Line_Item__c> updateList=new list<Product_Interest_Line_Item__c>();
for(Product_Interest_Line_Item__c pli :pliobj)
{
Map<Id,PricebookEntry> mapPe=new Map<Id,PricebookEntry>([select id, UnitPrice from PricebookEntry where Productcode = : pli.Product_code__c]);
for(Id id : mapPe.keySet())
{
pli.New_Price__c=mapPe.get(id).unitprice;
updateList.add(pli);
}
}
update updateList;
}
}
Thanks for your reply.. ! However how should i check for which pricebook , as in does it take the default pricebook associated to the record
Unfortunately , the code is not working.