UDS to open Contact Code List

SOLVED

I have been using UDS and BOI for a while and understand how to launch UIs. I'm just having trouble finding how to open the screens for searching. Specifically the Contact Code List that can be opened from Customer Maintenance by clicking on the magnifying glass next to Primary Contact. I have a need to track and display who the accounting contact for the customer is and wanted to allow someone to click a button, bring up the Contact Code List and select the appropriate contact. 

I basically just need help finding what business object to instantiate in order to open the Contact Code List.

Thanks,

Michael

  • 0 in reply to BadgerJerry
    AR_CustomerContact brings up a specific customer contact but I get an error 65 (object already exists or does not exist). Any Ideas?.
    I am also looking for the customer contact list. It shows all contacts for the given customer and allows the user to select one.
  • 0 in reply to mgm87
    verified answer

    Hi mgm87

    I am not sure what version of Sage 100 you are using, but in Version 2013, we introduced a function called InvokeLookup() as part of the oUIObj functionality.  So you can connect this to a button, and use the value comnig back and use a SetValue() to put it into your UDF.   Remember this will need to be run on the server.

    oUIObj.InvokeLookup(lookupCodevalue, {startValue})

    where:

    lookupCode - is the Code that used for the particular lookup you want to fire off.

    value - is the returned value when an item is selected from the list

    startValue - {optional} this should be populated when a list requires filtering such as Customer Contact where you'd only want to display just one customers contacts

    So you should be able to do something like:

    retval = 0
    arDiv = ""
    arCust = ""
    custLength = 0

    ' Use dictionary object to get column lengths for correct key padding
    custLength = oSession.AsObject(oSession.FileObj).GetColumnLength("AR_Customer", "CustomerNo$")

    retVal = oBusObj.GetValue("ARDivisionNo$", arDiv)
    retVal = oBusObj.GetValue("CustomerNo$", arCust)

    custSeed = arCust & String(custLength - Len(arCust), Chr(0))
    contact = ""

    retVal = oUIObj.InvokeLookup("AR_CustomerContact", contact, arDiv + custSeed)

    If retVal Then 

       retval = oBusObj.SetValue("UDF_Whatever$", contact)

    End If

     

    Hope this helps, Elliott.

  • 0 in reply to jepritch
    This worked great, thank you!

    There was just one change I needed to make it work. I needed to define oUIObj before calling InvokeLookup.
    The final code is:

    retval = 0
    arDiv = ""
    arCust = ""
    custLength = 0

    ' Use dictionary object to get column lengths for correct key padding
    custLength = oSession.AsObject(oSession.FileObj).GetColumnLength("AR_Customer", "CustomerNo$")

    retVal = oBusObj.GetValue("ARDivisionNo$", arDiv)
    retVal = oBusObj.GetValue("CustomerNo$", arCust)

    custSeed = arCust & String(custLength - Len(arCust), Chr(0))
    contact = ""

    Set oUIObj = oSession.AsObject(oSession.GetObject("AR_CustomerContact_ui"))
    retVal = oUIObj.InvokeLookup("AR_CustomerContact", contact, arDiv + custSeed)

    If retVal Then

    retval = oBusObj.SetValue("UDF_Whatever$", contact)

    End If

    Thanks again,
    mgm87
  • 0 in reply to jepritch

    Excellent post Elliot!!! Thanks for putting this out there. To be sure I understand how the InvoiceLookup method works (and not to hijack this thread from last week) I altered the script slightly to work with the AR_Salesperson table and I get this message

    The modified script is shown here and was run on the ABC company from a button on the Customer Main panel just like your original script:

    retval = 0
    arSPDiv = ""
    arSalespersonNo = ""
    custLength = 0

    ' Use dictionary object to get column lengths for correct key padding
    custLength = oSession.AsObject(oSession.FileObj).GetColumnLength("AR_Salesperson", "SalespersonNo$")

    retVal1 = oBusObj.GetValue("SalespersonDivisionNo$", arSPDiv)
    retVal2 = oBusObj.GetValue("SalespersonNo$", arSalespersonNo)
    MsgBox"retVal1 = " & retVal1 & "; retVal2 = " & retVal2 & "; arSPDiv = " & arSPDiv & "; arSalespersonNo = " & arSalespersonNo
    custSeed = arSalespersonNo & String(custLength - Len(arSalespersonNo), Chr(0))
    contact = ""

    retVal = oUIObj.InvokeLookup("AR_Salesperson", contact, arSPDiv + custSeed)
    MsgBox"InvokeLookup retVal = " & retVal
    If retValThen

       retval = oBusObj.SetValue("Comment$", contact)

    EndIf

    The 1st diagnostic MsgBox produces: "retVal1 = 1; retVal2 = 1; arSPDiv = 02; arSalespersonNo = 0400"
    The 2nd diagnosic MsgBox productes "InvokeLookup retVal = 0"

    I would be interested in your thoughts..

     

    Dan