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?
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:
- Extend AMProdItem dac by adding unbound copies of the "SOLineNbr", "SOOrderNbr", "SOOrderType" fields marked as aPXUIField(DisplayName =<FieldName>, Enabled = true, Visible = false)]
- 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) - Extend the MANUFACTURING endpoint and add these fields there
(see MFGEndpointExtensionforLinkSalesOrder.png) - 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"
}
}
That is awesome, thank you
Does anyone have an update for this in 24R1?
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.