Data Directive Duplicate PO's on Sales Orders

I am looking for detailed instructions on how to create a BPM or Data Directive to alert the entry person when they enter a duplicate PO#. I want them to move forward with their sales order entry, but they need to be aware that an existing PO# exists.

Does anyone have a BPM or data directive that they can attach or show instructions on how to create one?

Please note… on the customer maintenance screen three is a button to check for duplicates, but it is a hard stop and won’t let an order be created. We checked this box and order entry users can’t add a sales order! Our sales team just needs to know if a PO# exists.

I have read through the other posts, but it seems incomplete or not showing all the necessary steps.

For one, adding “tt” tables to a BAQ - how would I go about doing that?

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 :

I went with this code to solve the same issue, myself:

Erp.Tables.OrderHed OrderHed;

foreach(var item in ttOrderHed.Where(row => row.Added()||row.Updated()))
{
  if(item.PONum != null)
  {

    var Order = (from row in Db.OrderHed where row.Company == Session.CompanyID && row.PONum == item.PONum select row ).FirstOrDefault();
    if(Order != null)
    {
      string message = "PO#: '" + item.PONum + "' already exists on order " + Order.OrderNum;
      this.PublishInfoMessage(message, Ice.Common.BusinessObjectMessageType.Warning, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
    }
  }
}

You can use

image

Found on Customer Maintenance?

@aarong - Thanks, Aaron. This is what I went with first but it doesn’t check for duplicate PO numbers… rather, it disallows entering duplicate PO numbers on the sales order. I am unable to enter any duplicate PO#'s at all. It’s a hard stop.

@ckoch - I will try your code today. I was away for the Thanksgiving holidays and couldn’t respond back to your tip. Appreciate your quick response. I will give this a go.

@Shizar115 - Cool, thanks… I saw this one too but it wasn’t making sense to me. I will give this one a try, as well and see which one works best and let ya’ll know or if I need further assistance in creating my data directive.

@ckoch - I copied your code and the data directive works!!! Thanks so much for your help on this. Thank you so much!