Search code examples
vb.netdynamics-gp

Create a purchase order in Dynamics GP


My main question is what fields are required for creating a PO using the web services. I keep getting an exception, so I feel like im leaving some info out. Any ideas? Here is my code:

Public Sub CreatePurchaseOrder(ByVal shipToAddress As BusinessAddress,
                               ByVal billToAddressKey As AddressKey,
                               ByVal purchaseOrderLines As PurchaseOrderLine(),
                               ByVal venKey As VendorKey,
                               ByVal venName As String,
                               ByVal poDate As Date,
                               ByVal custKey As CustomerKey)
    Dim po As PurchaseOrder = New PurchaseOrder
    po.BillToAddressKey = billToAddressKey
    po.Lines = purchaseOrderLines
    po.ShipToAddress = shipToAddress
    po.VendorKey = venKey
    po.VendorName = venName
    po.Date = poDate
    po.CustomerKey = custKey
    po.Type = PurchaseOrderType.Standard



    Dim cxt As Context = getContext()
    Dim poPol = wsDynamicsGP.GetPolicyByOperation("CreatePurchaseOrder", cxt)
    wsDynamicsGP.CreatePurchaseOrder(po, cxt, poPol)
End Sub

Solution

  • To actually create it, all you need is a vendor key with an Id and an Purchase Key with an Id