Skip to main content

I’ve created a sales order with one line and a production order by Rest-API. I would like to link these orders by API. PUTing "SOLineNbr", "SOOrderNbr", "SOOrderType" into production order object doesn’t work. These fields stay null. The other way i get an error: "An error occurred during processing of the field AMProdOrdID: A numbering sequence for the order type is not configured.." Which is wrong.
Any ideas?

Can anybody give me clue?


@priekenberg40 , this cannot be done that straightforward.

Filling of the "SOLineNbr", "SOOrderNbr", "SOOrderType" fields should be the result of the LinkProductionOrders method. Filling these fields through API does not trigger this method

This might be addressed in  future versions, but now you should implement all this logic yourself.

You can use the following approach:

  1. Extend AMProdItem dac by adding unbound copies of the "SOLineNbr", "SOOrderNbr", "SOOrderType" fields marked as aPXUIField(DisplayName =<FieldName>, Enabled = true, Visible = false)]
  2. Add these fields to the .aspx page (they are not visible, so won’t appear in UI)

    See the attached customization which does (1), (2)
  3. Extend the MANUFACTURING endpoint and add these fields there 
    (see MFGEndpointExtensionforLinkSalesOrder.png)
  4. Write the logic which calls the LinkProductionOrders method when these fields are filled through API, like this:
public class AMProdMaintAPIExtension : PXGraphExtension<ProdMaint>
    {
        public virtual void AMProdItem_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e)
        {
            var row = (AMProdItem)e.Row;
            var oldRow = (AMProdItem)e.OldRow;
            if (row == null || !Base.IsContractBasedAPI)
            {
                return;
            }
            AMProdItemAPIExtension rowExtAPI = row.GetExtension<AMProdItemAPIExtension>();
            if (rowExtAPI == null)
            {
                return;
            }

                if (!cache.ObjectsEqual<AMProdItemAPIExtension.usrapiordLineRef, AMProdItemAPIExtension.usrApiordNbr,
                AMProdItemAPIExtension.usrApiordTypeRef>(oldRow, row))
            {
                var soLine = (SOLine)PXSelect<SOLine,
                        Where<SOLine.orderType, Equal<Required<SOLine.orderType>>,
                            And<SOLine.orderNbr, Equal<Required<SOLine.orderNbr>>,
                            And<SOLine.lineNbr, Equal<Required<SOLine.lineNbr>>>>>
                    >.SelectWindowed(Base, 0, 1, rowExtAPI.UsrApiOrdTypeRef, rowExtAPI.UsrApiOrdNbr,
                    rowExtAPI.UsrapiordLineRef);
                if (soLine == null)
                {
                    return;
                }
                PXGraph.CreateInstance<SOOrderEntry>()?.
                    GetExtension<SOOrderEntryAMExtension>()?.LinkProductionOrders(Base, soLine,
                    row);
            }
        }

    }

 

then PUT request with these new fileds filled will link the specified sales order to the production order created:

 {

    /*"ProductionNbr": {

        "value": "<NEW>"

    },*/

    "OrderType": {

        "value": "RO"

    },

    "InventoryID": {

        "value": "MGBASE"

    },

    "note": "",

    "Warehouse": {

        "value": "WHOLESALE"

    },

    "QtytoProduce": {

        "value": "2"

    },

    "SOLineNbrAPI": {

        "value": "1"

    },

      "SOOrderNbrAPI": {

        "value": "SO006539"

    },

      "SOOrderTypeAPI": {

        "value": "SO"

    }



}

 


@mvolshteyn Great idea! Haven’t thought of such an approach up to now. I’ll try this the next days...


That is awesome, thank you @mvolshteyn 


Does anyone have an update for this in 24R1?


Reply