Skip to main content
Answer

Stop execution of action

  • September 18, 2024
  • 6 replies
  • 102 views

Forum|alt.badge.img+1

Hi,

Im overriding action of creating shipment on sales order screen. I need stop execution of all processes.

Is there any way I can stop execution of all processes in overrided action?

I tried to use

throw new PXException(msg);

but it only shows exception and continued execution.

Best answer by darylbowman

Sorry, I made one error. Try this:

public delegate IEnumerable CreateShipmentDelegate(PXAdapter adapter,
[PXDate] DateTime? shipDate,
[PXInt] int? siteID,
[SOOperation.List] string operation);
[PXOverride]
public virtual IEnumerable CreateShipment(PXAdapter adapter,
[PXDate] DateTime? shipDate,
[PXInt] int? siteID,
[SOOperation.List] string operation,
CreateShipmentDelegate baseMethod)
{
List<SOOrder> list = adapter.Get<SOOrder>().ToList();

string msg = "Fix qty for ";
throw new PXException(msg);
return list; // Or: return baseMethod(adapter, shipDate, siteID, operation);
}

 

6 replies

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

Could you share that part of your code? Usually, throwing a PXException will work, unless it’s being caught somehow.


Forum|alt.badge.img+1
  • Author
  • Varsity I
  • September 19, 2024

Sure 

public class SOOrderEntry_Extension : PXGraphExtension<PX.Objects.SO.SOOrderEntry>
{

public delegate IEnumerable CreateShipmentDelegate(PXAdapter adapter);
[PXOverride]
public IEnumerable CreateShipment(PXAdapter adapter,
[PXDate] DateTime? shipDate,
[PXInt] int? siteID,
[SOOperation.List] string operation)
{
List<SOOrder> list = adapter.Get<SOOrder>().ToList();

string msg = "Fix qty for ";
throw new PXException(msg);
return list;
}
}

 


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

Your delegate needs to match the original method:

public delegate IEnumerable CreateShipmentDelegate(PXAdapter adapter,
[PXDate] DateTime? shipDate,
[PXInt] int? siteID,
[SOOperation.List] string operation);
[PXOverride]
protected virtual IEnumerable CreateShipment(PXAdapter adapter,
[PXDate] DateTime? shipDate,
[PXInt] int? siteID,
[SOOperation.List] string operation,
CreateShipmentDelegate baseMethod)
{
List<SOOrder> list = adapter.Get<SOOrder>().ToList();

string msg = "Fix qty for ";
throw new PXException(msg);
return list; // Or: return baseMethod(adapter, shipDate, siteID, operation);
}

 


Forum|alt.badge.img+1
  • Author
  • Varsity I
  • September 19, 2024

Thanks for reply. After correction of delegate still no iterruption(


darylbowman
Captain II
Forum|alt.badge.img+15
  • Answer
  • September 19, 2024

Sorry, I made one error. Try this:

public delegate IEnumerable CreateShipmentDelegate(PXAdapter adapter,
[PXDate] DateTime? shipDate,
[PXInt] int? siteID,
[SOOperation.List] string operation);
[PXOverride]
public virtual IEnumerable CreateShipment(PXAdapter adapter,
[PXDate] DateTime? shipDate,
[PXInt] int? siteID,
[SOOperation.List] string operation,
CreateShipmentDelegate baseMethod)
{
List<SOOrder> list = adapter.Get<SOOrder>().ToList();

string msg = "Fix qty for ";
throw new PXException(msg);
return list; // Or: return baseMethod(adapter, shipDate, siteID, operation);
}

 


Forum|alt.badge.img+1
  • Author
  • Varsity I
  • September 19, 2024

Thanks. That worked!