• Sarath PM
  • NEWBIE
  • 0 Points
  • Member since 2013

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

 

public class LastOfferPrice {
	public ID OpportunityID{get; set;}
	
	
	List<OpportunityLineItem> Item;
	public List<OpportunityLineItem> getItem(){
        if(Item==null){
        Item = [Select Id,PricebookEntry.Product2.Name,ListPrice,UnitPrice,Opportunity.CloseDate,LastModifiedDate From OpportunityLineItem Where OpportunityId=:OpportunityID ORDER BY PricebookEntry.Product2.Name DESC]; 
       }
        return Item;
    }

    List<OpportunityLineItem> LastOffer;
    
    public List<OpportunityLineItem> getLastOffer(){
    	
        for(OpportunityLineItem I:Item){
        	
	      LastOffer = [Select Id,distinct (PricebookEntry.Product2.Name,ListPrice),UnitPrice,LastModifiedDate 
	      From OpportunityLineItem Where LastModifiedDate <= YESTERDAY and PricebookEntry.Product2.Name=:I.PricebookEntry.Product2.Name ORDER BY ID DESC ]; 

	       }
	      return LastOffer;
    }

}

 Is error How to query not duplicate name of product