Skip to main content
Answer

Sales Order Workflow Customization - Making field required on a condition

  • July 14, 2025
  • 5 replies
  • 65 views

Hi

I am trying to make a field required when a customer tax zone is specific on the SO order type. The problem i am having is making this field required when trying to create a shipment. So the field will not be required on SO creation, but rather when trying to invoice.

Best answer by Django

Probably the easiest way would be to do the test in an override of the .Persist method. That will allow you to prevent the invoice from being saved if the conditions aren’t met.

public delegate void PersistDelegate();
[PXOverride]
public void Persist(PersistDelegate baseMethod)
{

ARInvoice row = Base.Document.Current;
ARInvoiceExt rowExt = row.GetExtension<ARInvoiceExt>();

if (row != null)
{
//do your test here. If the record fails, throw a PXException.
}


baseMethod();
}

 

5 replies

Forum|alt.badge.img+7
  • Captain II
  • July 14, 2025

Do you want to prevent the invoice from being created at all or do you want to prevent the invoice from being printed or released until the field requirements have been met?


  • Author
  • Freshman I
  • July 14, 2025

Hi Django
I want to prevent the invoice being created, this will will need to be populated for specific customers. 


Forum|alt.badge.img+7
  • Captain II
  • Answer
  • July 14, 2025

Probably the easiest way would be to do the test in an override of the .Persist method. That will allow you to prevent the invoice from being saved if the conditions aren’t met.

public delegate void PersistDelegate();
[PXOverride]
public void Persist(PersistDelegate baseMethod)
{

ARInvoice row = Base.Document.Current;
ARInvoiceExt rowExt = row.GetExtension<ARInvoiceExt>();

if (row != null)
{
//do your test here. If the record fails, throw a PXException.
}


baseMethod();
}

 


  • Author
  • Freshman I
  • July 16, 2025

Hi Django

Thanks will give this a try and let you know if all is good.


Forum|alt.badge.img+8
  • Captain II
  • July 16, 2025

Hi ​@JonaS 

 

Alternatively, you can disable the action by creating a condition which causes the ‘Prepare Invoice’ to be disabled.

 

 

Hope this helps!