• softwaren
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies

Hi.İ have an object which name is order.This is like opportunity object and it must work syncronised with opportunity.İ fixed to add,delete and update order and same record which is on opportunity.İ want to do this operations on line items.When i add an order line item i must see this item under the opportunity record of same order.Please help me.This is so important for me.This is my codes but i got an error like " DUPLICATE_VALUE, This price definition already exists in this price book: []: Class.OrderItemToOppHandler.onBeforeInsert: line 11, column 1".Could you help me pls??

this is my class

public class OrderItemToOppHandler {

public void onBeforeInsert(List<Order_Products__c> OrdLineList){

List<OpportunityLineItem> OppItemToAdd = new List<OpportunityLineItem>();
List<PriceBookEntry> PRBList = new List<PriceBookEntry>();
PriceBook2 pr = [Select Id from PriceBook2 limit 1];
for (Order_Products__c ordp : OrdLineList) {
PRBList.add(new PriceBookEntry(pricebook2Id=pr.Id,product2Id=ordp.Product__c,unitprice=500));
}
insert PRBList;

for (Order_Products__c ordp : OrdLineList) {

OpportunityLineItem item = new OpportunityLineItem(Opportunityid = ordp.Order__c,PriceBookEntryId=PRBList[0].Id,Quantity=ordp.Quantity__c,ServiceDate=ordp.Date__c,UnitPrice=ordp.Sales_Price__c,TotalPrice=ordp.Total_Price__c );

OppItemToAdd.add(item);
}
insert OppItemToAdd;

}

}

 

hi.İm new on apex and i have a project.İ designed a custom object which name is order__c.İts works like opportunity.İ want to make it working syncronised with opportunity.When i create an order record it an be add on opportunity as same name and same properties(ordername,account,close date,) i fixed it no problem.But also i need to do these too.When i add an order line item(related to product) on order it can be added the same time on opportunity line item on the record which is in same name.Also i need to update the opportunity record which is created from order.Could you help me please???

Hi.İ have an object which name is order.This is like opportunity object and it must work syncronised with opportunity.İ fixed to add,delete and update order and same record which is on opportunity.İ want to do this operations on line items.When i add an order line item i must see this item under the opportunity record of same order.Please help me.This is so important for me.This is my codes but i got an error like " DUPLICATE_VALUE, This price definition already exists in this price book: []: Class.OrderItemToOppHandler.onBeforeInsert: line 11, column 1".Could you help me pls??

this is my class

public class OrderItemToOppHandler {

public void onBeforeInsert(List<Order_Products__c> OrdLineList){

List<OpportunityLineItem> OppItemToAdd = new List<OpportunityLineItem>();
List<PriceBookEntry> PRBList = new List<PriceBookEntry>();
PriceBook2 pr = [Select Id from PriceBook2 limit 1];
for (Order_Products__c ordp : OrdLineList) {
PRBList.add(new PriceBookEntry(pricebook2Id=pr.Id,product2Id=ordp.Product__c,unitprice=500));
}
insert PRBList;

for (Order_Products__c ordp : OrdLineList) {

OpportunityLineItem item = new OpportunityLineItem(Opportunityid = ordp.Order__c,PriceBookEntryId=PRBList[0].Id,Quantity=ordp.Quantity__c,ServiceDate=ordp.Date__c,UnitPrice=ordp.Sales_Price__c,TotalPrice=ordp.Total_Price__c );

OppItemToAdd.add(item);
}
insert OppItemToAdd;

}

}

 

hi.İm new on apex and i have a project.İ designed a custom object which name is order__c.İts works like opportunity.İ want to make it working syncronised with opportunity.When i create an order record it an be add on opportunity as same name and same properties(ordername,account,close date,) i fixed it no problem.But also i need to do these too.When i add an order line item(related to product) on order it can be added the same time on opportunity line item on the record which is in same name.Also i need to update the opportunity record which is created from order.Could you help me please???