I have a use case where in 1 Order Contains multiple OrderItems, and these orderitems contains records. lets say there are 5 orderitems to 1 order, and among 5 orderitems 2 are duplicate and 3 are unique, so my question is how do i remove these 2 duplicates and how should i compare the list of 5 orderitems with each other to delete it.
Here is my code.
/*****************************
Map<Id,Order> ord = new Map<Id,Order>([Select id from Order LIMIT 50]);
Set<Id> ordId = new Set<Id>();
Set<Id> ordId1 = new Set<Id>();
Set<Id> ordId2 = new Set<Id>();
Set<Id> ordId3 = new Set<Id>();
Set<Decimal> ordId4 = new Set<Decimal>();
Set<Decimal> ordId5 = new Set<Decimal>();
Set<Number> ordId6 = new Set<Number>();
for(Order o : ord.values())
{
List<OrderItem> ordListItem = [Select OrderId,ebMobile__Product2__c,Product2Id,ebMobile__ErpProductCode__c,ListPrice,UnitPrice,Quantity,
ebMobile__LineType__c,ebMobile__BaseUOM__c,ebMobile__IsActive__c,
AvailableQuantity,ebMobile__UOMCode__c,ebMobile__ReceivedQuantity__c From OrderItem where OrderId =: o.Id];
for(OrderItem items : ordListItem)
{
if(ordId4.contains(items.ListPrice) && ordId5.contains(items.UnitPrice) && ordId6.contains(Quantity))
{
ordId.add(items.id);
}
}
}
*****************************/