Solved

block duplicate Customer Order Nbr just for the "SO" order type

  • 3 May 2023
  • 6 replies
  • 77 views

Userlevel 1

i have code to block duplicate Customer Order Nbr, but i want it should be filtered just for the “SO” Order Type.

how can i do that? 

 

  [PXCheckUnique(Where = typeof(Where2<Where<SOOrder.orderType, Equal<Current<SOOrder.orderType>>,
        And<SOOrder.customerOrderNbr, Equal<Current<SOOrder.customerOrderNbr>>,
            And<SOOrder.customerID, Equal<Current<SOOrder.customerID>>>>>, 
        And<SOOrder.status, NotEqual<SOOrderStatus.cancelled>>>),
        ErrorMessage = "Order already exists with this Customer Order Nbr and Customer ID ")]

icon

Best answer by darylbowman 3 May 2023, 19:23

View original

6 replies

Userlevel 7
Badge +12

Hi @yoelb 

Can you use customer order Nbr validation on  order types,

Userlevel 1

Hi @manikantad18 ,

 

to use the built in validation it needs to be checked “Require Customer Order Nbr”, and it will not allow to be empty, which will not work for us

 

Userlevel 5
Badge +2

@yoelb Try adding a fieldUpdated event for CustomerOrderNbr, do the search and raise an error if another order has the same customer order:
 

public void SOOrder_CustomerOrderNbr_FieldUpdated(...){
if(e.Row == null) return;
if(PXSelect<SOOrder, Where<SOOrder.customerOrderNbr, Equal<Required<SOOrder.customerOrderNbr>>,
And<SOOrder.orderType, NotEqual<Required<SOOrder.orderType>>,
And<SOOrder.orderNbr, NotEqual<Required<SOOrder.orderNbr>>>>>>
.Select(Base, e.Row.CustomerOrderNbr, e.Row.OrderType, e.Row.OrderNbr)
.Count() > 0)
{
throw new PXException("Another order has same customer order...");
}
}

Probably you would need to implement this same validation in RowPersisting event to make it more robust.

Badge +11

You could put the constant SOOrderTypeConstants.salesOrder in the BQL statement, but without knowing the situation, I can’t recommend that it would be a good idea.

 

[PXCheckUnique(Where = typeof(
Where2<
Where<SOOrder.orderType, Equal<SOOrderTypeConstants.salesOrder>,
And<SOOrder.customerOrderNbr, Equal<Current<SOOrder.customerOrderNbr>>,
And<SOOrder.customerID, Equal<Current<SOOrder.customerID>>>>>,
And<SOOrder.status, NotEqual<SOOrderStatus.cancelled>>>
), ErrorMessage = "An 'SO' Order already exists with this Customer Order Nbr and Customer ID ")]

 

Userlevel 1

@darylbowman  -  Thank you

Userlevel 5
Badge

Hello,

Here is the Screen ID in 23R1 to change the Customer Order Nbr. Validation.

Order Types (SO201000)

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved