Data Directive Duplicate PO's on Sales Orders

Hi @aberdeenmeadows ,

Update: I miunderstood the first time, so you are entering the PO in your system which means it is actually an SO in your system. For that the table will change. I have revised the code. Sorry for the confusion.

Try adding the CustomCode block and then this code inside it.
I did not include the messagebox code since that in my opinion is a separate question. Also note that just the similar PO# in my opinion is not a good criteria so I added custnum as well, feel free to remove it:

string company ="";
int PONum = 0;
int CustNum = 0;


if(ttOrderHed.Any())

{
    foreach(var ttOrderHedrow in ttOrderHed)
	{
        company = (ttOrderHedrow.Company).toString();
        PONum = ttOrderHedrow.PONum;
        CustNum = ttOrderHedrow.CustNum;
    
    
                                 
                                 
          	 foreach (var OrderHedRow in (from OrderHed_Row in Db.OrderHedHeader
          		where  OrderHed_Row.Company == company && OrderHed_Row.PoNum == PONum && OrderHed_Row.CustNum == CustNum 
          		select OrderHed_Row))
          		{
			//Your code for action goes here (could be an email, a messagebox, ...)

			}
          	
                                 
          
          
	}

}

For messagebox give this a try:

string body = "Your Message Here";
		this.PublishInfoMessage(body, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "FirstVar","SecondVar");

I got this code from this topic, thanks to @Aaron_Moreng :