Hi Team,
We have a requirement where we have to import BigCommerce orders with Invoice order template and have to Prepare & Release Invoice subsequently for this order.
We are able to import orders with Invoice order template. Now, when we are trying to execute Prepare Invoice action using Base.prepareInvoice.Press(); we are getting errors like: The Prepare Invoice action is not available in the Sales Order: Order Type = IN; Order Nbr. = AR010201 document at the moment. The document is being used by another process. or simply Invoice.
Â
Please find below code piece for review that have tried:
Approach 1: Results in error -Â The Prepare Invoice action is not available in the Sales Order: Order Type = IN; Order Nbr. = AR010201 document at the moment. The document is being used by another process.
public delegate void PersistDelegate();
    ÂPXOverride]
    public void Persist(PersistDelegate basemethod)
    {
      basemethod();
      if (Base.Document.Current.xyz == "") //Condition to prevent multiple execution of below prepare invoice action
        Base.prepareInvoice.Press();
    }
Â
Approach 2: Results in error - Invoice.
protected virtual void SOOrder_RowPersisted(PXCache sender, PXRowPersistedEventArgs e, PXRowPersisted baseEvent)
    {
      baseEvent(sender, e);
      SOOrder row = e.Row as SOOrder;
      if (row == null) return;
      if (e.TranStatus == PXTranStatus.Completed && Base.Document.Current.xyz == "") //Condition to prevent multiple execution of below prepare invoice action
        Base.prepareInvoice.Press();
    }
Â
Can someone suggest the best possible approach to achieve this please.
Thank you in advance!