Search code examples
vb.netaxaptadynamics-ax-2009aif

vb.Net code to use AX 2009 ReturnOrderInService web service


Need to use the create method of the AX 2009 ReturnOrderInService web service in a vb.NET aspx page to create an RMA in AX.

The code I've written below creates the RMA in AX, but doesn't show the line details in the AX RMA form, even though the records are in SalesTable and SalesLine.

Is a record needed in InventTrans or is there a missing InventRefId value somewhere?


    Dim rmaClient As ReturnOrderInServiceClient = New ReturnOrderInServiceClient("WSHttpBinding_ReturnOrderInService1")
    Dim roi As AxdReturnOrderIn = New AxdReturnOrderIn

    Dim st As AxdEntity_SalesTable = New AxdEntity_SalesTable
    st.CustAccount = "123"
    st.ReturnReasonCodeId = "RRC1"
    st.DlvMode = "01"
    st.SalesType = 4  'return item
    st.ReturnDeadline = DateAdd(DateInterval.Day, 15, Now())

    Dim sl As AxdEntity_SalesLine = New AxdEntity_SalesLine
    sl.ItemId = "ITEM 123"        
    sl.ExpectedRetQty = -2
    sl.LineAmount = 0           
    sl.InventTransIdReturn = "" 

    st.SalesLine = New AxdEntity_SalesLine() {sl}
    roi.SalesTable = New AxdEntity_SalesTable() {st}

    txtFeedback.Text = ""

    Try
        Dim returnedSalesOrderEntityKey As EntityKey() = rmaClient.create(roi)
        Dim returnedSalesOrder As EntityKey = CType(returnedSalesOrderEntityKey.GetValue(0), EntityKey)            
        txtFeedback.Text = GetRMANo(returnedSalesOrder.KeyData(0).Value)
    Catch ex As Exception
        txtFeedback.Text = ex.Message
    End Try

    rmaClient.Close()

Solution

  • Did you generate the proxy classes as stated in http://msdn.microsoft.com/en-us/library/cc652581(v=ax.50).aspx? This should create the AxdEntity classes needed.

    First I would try to translate the example to VB. I cannot help you with the specific syntax, but there is nothing fancy here, so it should be rather simple.

    Regarding the use of web services in AX, see also: