Acumatica AddPurchaseOrderLine Tip

I couldn’t find this tip in the Acumatica Web Services T210 (v.4.2) or I210 (v5.3) training material so I thought I’d create a post about it. Ruslan Devyatko in Acumatica Support provided this to me. I used it successfully with Acumatica version 5.1.

When creating a new Purchase Receipt using the Acumatica Screen-Based Web Services from an existing Purchase Order it’s necessary to “click” a button to get the Add Purchase Order Line dialog to pop-up. That’s documented in the I210 training, but in the different context of creating a Shipment for a Sales Order.

Rather than use CreateShipmentAction with commit, the Purchase Receipt form has two methods, one to open the pop-up panel (AddPOOrderLine) and another to close and add the selected lines (AddPOOrderLine2), which you use with commit just like in the Shipment example. One might guess this, but there is another piece that I never would have guessed, that is how to modify specific lines based on the InventoryID. The trick is to use string.Format with the format shown below. My example uses a variable, “myIndex”. You can use that while iterating the collection or to search for a specific line.

  new Key   {
      ObjectName = schema.AddPurchaseOrderLine.InventoryID.ObjectName,
      FieldName = schema.AddPurchaseOrderLine.InventoryID.FieldName,
      Value = string.Format("='{0}'", poLines[myIndex].AddPurchaseOrderLine.InventoryID.Value)

That’s a zero between the curly braces, as you probably knew. Using the string.Format method like this, with the Acumatica Web Services, isn’t documented anywhere that I could find. Once you select a line that matches one on the receipt and add the Key command for the InventoryID as shown, you can change the quantity received for that item, using the same index, since the quantity received may differ from quantity on the purchase order. Selecting the line, or checking the pop-up panel’s checkbox, is the same as shown in the shipment example, but here it is for the Purchase Receipt form.

  new Value {
     Value = "True",
     LinkedCommand = schema.AddPurchaseOrderLine.Selected,
     Commit = true

You can then call AddPOOrderLine2 to add the lines to the receipt and close the panel.

Leave a Reply

2 × five =