Skip to main content
Solved

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


  • Freshman II
  • 7 replies

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 ")]

Best answer by darylbowman

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 ")]

 

View original
Did this topic help you find an answer to your question?

6 replies

Manikanta Dhulipudi
Captain II
Forum|alt.badge.img+13

Hi @yoelb 

Can you use customer order Nbr validation on  order types,


  • Author
  • Freshman II
  • 7 replies
  • May 3, 2023

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

 


Dioris Aguilar
Jr Varsity I
Forum|alt.badge.img+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.


darylbowman
Captain II
Forum|alt.badge.img+13

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 ")]

 


  • Author
  • Freshman II
  • 7 replies
  • May 3, 2023

@darylbowman  -  Thank you


AndrewBGL
Pro I
Forum|alt.badge.img
  • Pro I
  • 175 replies
  • July 19, 2023

Hello,

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

Order Types (SO201000)


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings