+ Start a Discussion
RajeevlsHydRajeevlsHyd 

Limit the record count while inserting into a list

I have a requirement to have only 5 rows added to a list (dealsplit -  mentioned below).  here is the code . Ho can we implement it

-------------------------------------------------------------------------------------------

public PageReference addSelectedProductAction()
{
for(ProductWrapper pw: products){
if(pw.isSelected){
pw.addDealSplitAction();
selectedProds.add(pw);
}
}
return null;
}

public PageReference addDealSplitAction(){
DealSplitWrapper dealSplit = new DealSplitWrapper(product);
dealSplits.add(dealSplit);

return null;
}

-----------------------------------------------------------------------------------------------------

 

thanks

Satish_SFDCSatish_SFDC
while adding dealSplits sorround it with a condition:

if(dealSplits.size()<5){
dealSplits.add(dealSplit);
}


Regards,
Satish Kumar
RajeevlsHydRajeevlsHyd

Thanks for replying...
Can I add an error message here so that if the count is more than it throws an error