Button Script on Customer Maintenance to open UDT maintenance UI for a particular AR_UDT. The second step would be to pass the Customer Number to the CM_UDTMaintSelect_UI

We would like a Button Script on Customer Maintenance to open UDT maintenance UI for a particular AR_UDT.

The second step would be to pass the Customer Number to the CM_UDTMaintSelect_UI. This would work great as there are multiple records in the UDT for a customer.

I have previously written an Inventory Maintenace Button Script that Launches "BM_BillWhereUsedInquiry_UI" and passes the Item Code from Item Maintenance. I thought it would be similar but I can't get this UDT script to work.

If the Button Script is a problem we might be able to connect it to a Table Event.

  • 0

    Here is the script and the error I receive.

    'CM_UDTMaintSelect_UI
    'CM_UDTMaint_Bus
    'CM_UDTMaint_UI
    'CM_UDT_Svc
    '
    oUDTMaint = 0
    oUDTMaintUI = 0
    custDiv = ""
    custNo = ""
    searchUDTCust = ""


    retVal = oBusObj.GetValue("ARDivisionNo$",CustDiv)
    retVal = oBusObj.GetValue("CustomerNo$",custNo)

    searchUDTCust = custDiv & custNo

    searchUDTCust =Trim(Cstr(searchUDTCust))

    'not sure how to pass this to CM_UDTMaintSelect_UI

    if Not(IsObject(oUDTMaintUI)) Then
    Set oUDTMaintUI = oSession.AsObject(oSession.GetObject("CM_UDTMaint_UI","AR_UDT_CUSTOMER_GATE_INFO"))

    If oUDTMaintUI <> 0 Then
    Set oUDTMaintUI = oSession.AsObject(oUDTMaintUI)
    End if
    End if

    retVal = oUDTMaintUI.LoadGrid "GD_Lines"

    Here is the User Defined Table  Maintenance screen with the Selection screen open. I would like to open UDT Maint and pass the searchUDTCust value from the script to the UDT Selection field Customer_ID 

  • 0 in reply to Mark LaBarge

    If anyone can offer assistance on this it would be greatly appreciated.

  • 0 in reply to Mark LaBarge

    Just stumbled across this post from a while ago. I assume you probably fixed it by now but that type of error usually is typically related to compile issues than something with the code.

    Any time you pass arguments to a property/function/method and you are setting it equal to something, you need to enclose those arguments in parenthesis.

    retVal = oUDTMaintUI.LoadGrid "GD_Lines"

    needs to be:

    retVal = oUDTMaintUI.LoadGrid("GD_Lines")

    unrelated to the error, but this would probably turn into a run-time error after you fixed this one, any time you use the "Set" keyword, you are making an "Object" variable, which means it would never be equal to 0..

        Set oUDTMaintUI = oSession.AsObject(oSession.GetObject("CM_UDTMaint_UI","AR_UDT_CUSTOMER_GATE_INFO"))
        
        If oUDTMaintUI <> 0 Then
            Set oUDTMaintUI = oSession.AsObject(oUDTMaintUI)
        End if

    so the above statement should look like this:

        nUDTMaintUI = oSession.GetObject("CM_UDTMaint_UI","AR_UDT_CUSTOMER_GATE_INFO")
        
        If nUDTMaintUI <> 0 Then
            Set oUDTMaintUI = oSession.AsObject(nUDTMaintUI)
        End if

    In your case, your variables beginning with an "o" should refer to it being an object of some sort. The first line would be returning a number, so you should begin those variables with "n" (or i/int or whatever you're using to distinguish these). If you're going to use type prefixes on your variables you should stay true to them. I just stick with n (number) because l (lower case "L") doesn't look right for me when being specific on the actual number type.