0

I have a user field on the Purchase Order screen that I'd like to populate from the 'Production Nbr.' field during the 'Create Purchase Orders' process. The 'Production Nbr.' field shows up in the 'Create Purchase Orders' process screen as shown below:

enter image description here

The process screen:

enter image description here

I've located the method that I think is used to create the Purchase Orders:

public virtual PXRedirectRequiredException CreatePOOrders(List<POFixedDemand> list, DateTime? PurchDate, bool extSort, int? branchID = null)

But I'm afraid I don't know how to override this to get the job done. In a previous, similar situation, I've overridden the process method to add a RowInserting.AddHandler to set this field during the RowInserting event - but I'm not sure of the syntax in this situation...

Any help would be appreciated. Thanks.

pmfith
  • 831
  • 6
  • 24

1 Answers1

0

We use something similar in production. If only one PO was created, you have the POOrderEntry graph with the new PO. If more than one were created, you won't have the graph, you need to find the new POs using your POFixedDemand list parameter.

    public delegate PXRedirectRequiredException CreatePOOrdersDelegate(List<POFixedDemand> list,
        DateTime? PurchDate, bool extSort, int? branchID = null);

    [PXOverride]
    public virtual PXRedirectRequiredException CreatePOOrders(List<POFixedDemand> list, DateTime? PurchDate,
        bool extSort, int? branchID = null, CreatePOOrdersDelegate baseMethod = null)
    {
        var redirect = baseMethod?.Invoke(list, PurchDate, extSort, branchID);

        if (redirect != null)
        {
            // Only one PO was created
            if (redirect.Graph is POOrderEntry poGraph)
            {
                //Your new PO is here: poGraph.Document.Current;
            }
            else
            {
                //Something went wrong, redirect.Graph must be POOrderEntry
            }
        }
        else
        {
            // More than one PO were created, you need to find them somehow using List<POFixedDemand> list
            // parameter of this function.
        }

        return redirect;
    }
Zoltan Febert
  • 471
  • 5
  • 9