Finding duplicate sales or purchase lines

Hi guys,

Today, I am facing an issue about finding duplicate lines in sales or purchase order form. I have to write the code to find duplicate sales or purchase lines when the user enters the line details from form. If he enters duplicate lines then a warning message should appear saying that you have entered duplicate lines.

So, my question is where to write the code to find duplicate lines means in which method of form datasource or somewhere else.

Please reply me as soon as possible.

Thanks in advance!

If you want to run the validation when saving the line, which is the most common approach, implement it in validateWrite() method.