Skip to main content
Solved

Stop execution of action

  • 18 September 2024
  • 6 replies
  • 51 views

Forum|alt.badge.img
  • Jr Varsity III
  • 26 replies

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);
}

 

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

6 replies

darylbowman
Captain II
Forum|alt.badge.img+13
  • 1587 replies
  • September 18, 2024

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


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 26 replies
  • 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+13
  • 1587 replies
  • September 19, 2024

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
  • Author
  • Jr Varsity III
  • 26 replies
  • September 19, 2024

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


darylbowman
Captain II
Forum|alt.badge.img+13
  • 1587 replies
  • 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
  • Author
  • Jr Varsity III
  • 26 replies
  • September 19, 2024

Thanks. That worked!


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