Sage 100

 View Only
  • 1.  Has anyone been able to filter a UDF lookup validated w/UDT

    Posted 03-27-2020 01:38
    With a regular lookup one can use the Lookup Wizard to add a "New Field" and use it as a filter, but the "New Field" button is not available for lookups with UDT validated UDF's. I am looking to provide a lookup filtered by another field on the same table as the UDF. Specifically, a UDF on CI_ITEM where the UDT is filtered by ProductLine where the ProductLine could be a field in the UDT and/or the prefix of the key field. Any ideas?

    ------------------------------
    Dan Burleson
    Software Consultant
    Connex Software
    Corvallis OR
    541-224-6642
    ------------------------------


  • 2.  RE: Has anyone been able to filter a UDF lookup validated w/UDT

    Posted 03-27-2020 12:31
    Edited by Alnoor Cassim 03-27-2020 19:28
    InvokeLookup might work. Create your own button for the user to click to show a filtered ALE Lookup of your UDT instead of them clicking the Lookup button that is part of the UDF control (that button to the right of your Multi_Line UDF got added when in UDF Maint you validated against the UDT). You may want to disable / lock the UDF control so they can only press your button which you've placed right next to it.

    Below is example of InvokeLookup on AR_CustomerContact that has the Div and Customer No as the start value filter. If you can find the Lookup Code for your CI_Item UDF / UDT lookup then you can pass that in as Arg 1 and pass into Arg 3 your Product Line as the starting value. It assumes you have prefixed your UDT data on the key field with Product Line. Hope this helps.

    retVal = oBusObj.GetValue("ARDivisionNo$", sDiv) : retVal = oBusObj.GetValue("CustomerNo$", sCust)
    LookupCode = "AR_CustomerContact"
    'One way to get LookupCode is by watching variable Control$ when clicking the Customer Contact Lookup button
    rtnVal = ""
    'On regular table with a multi-part key (not a UDT) you have to null pad all the key parts except last one.
    'to full column length. That's why Customer No is padded here but Contact Code is not.

    rLookup = oUIObj.InvokeLookup(LookupCode, rtnVal, sDiv & sCust + String(20 - Len(sCust),chr(0)))
    'rtnVal will store what the user selected from the ALE lookup listbox that appeared
    'rLookup is just whether the method succeeded or not.

    If rLookup <> 0 and rtnVal <> "" Then
    ...

    ------------------------------
    Alnoor Cassim

    Accounting Systems, Inc. (ASI)
    Email: alnoor@asifocus.com
    Orange County, CA
    ------------------------------



  • 3.  RE: Has anyone been able to filter a UDF lookup validated w/UDT

    Posted 03-27-2020 19:27
    Thanks @Alnoor Cassim I can't wait to try and report.​

    ------------------------------
    Dan Burleson
    Software Consultant
    Connex Software
    Corvallis OR
    541-224-6642
    ------------------------------



  • 4.  RE: Has anyone been able to filter a UDF lookup validated w/UDT

    Posted 03-31-2020 04:24
      |   view attached
    Reporting back...the InvokeLookup works well for "AR_CustomerContact", but it doesn't seem to work for a UDT. I found the lookup code (Control$). My UDT key is 8 bytes. The 1st 4 are the ProductLine and the 2nd 4 are a sub product line code.  If I use a [StartValue] of a product line (e.g. "DCBA") or if I use a [StartValue] of the entire key (e.g. "DCBASUBZ"), the lookup dialog always shows all the UDT entries and is always positioned on the top line. I'm wondering if this doesn't work for UDT's.

    sProductLine = CI_ItemCode_bus_ProductLine
    
    LookupCode = "IMUDTSUBPRODLINE"
    'One way to get LookupCode is by watching variable Control$ when clicking the Customer Contact Lookup button
    rtnVal = ""
    'On regular table with a multi-part key (not a UDT) you have to null pad all the key parts except last one.
    'to full column length. That's why Customer No is padded here but Contact Code is not.
    
    rLookup = oUIObj.InvokeLookup(LookupCode, rtnVal, sProductLine)' & sCust + String(20 - Len(sCust),chr(0)))
    'rtnVal will store what the user selected from the ALE lookup listbox that appeared
    'rLookup is just whether the method succeeded or not.
    
    If rLookup <> 0 and rtnVal <> "" Then
    	MsgBox "Using ProductLine: '" & sProductLine & "' InvokeLookup returned: " & rtnVal
    Else
    	MsgBox "Using ProductLine: '" & sProductLine & "' InvokeLookup returned nothing: " & rtnVal
    End If​


    ------------------------------
    Dan Burleson
    Software Consultant
    Connex Software
    Corvallis OR
    541-224-6642
    ------------------------------



  • 5.  RE: Has anyone been able to filter a UDF lookup validated w/UDT

    Posted 03-31-2020 10:56
    Gotcha. Thx for the detail. I'll see what I can found out.

    ------------------------------
    Alnoor Cassim

    Accounting Systems, Inc. (ASI)
    Email: alnoor@asifocus.com
    Orange County, CA
    ------------------------------



  • 6.  RE: Has anyone been able to filter a UDF lookup validated w/UDT
    Best Answer

    Posted 03-31-2020 17:05

    So taking a look under the hood shows Start Filter does NOT work for most lookups on InvokeLookup! Son of a gun! So here is another way. I tried this out on an old project involving a Tax Schedule lookup button and it worked. Just substitute the vbsLookupCode and vbsField below with your own values. 

    'InvokeLookup does NOT support the Start Filter of most lookups
    'oUIObj.InvokeLookup(LookupCode, rtnSelected, startFilter)

    'So we need to emulate this and send the Field$ as the filter. It will also be rtn value
    ' CALL "SY_Lookup.m4p;Called",LookupCode$,Status,$$,startVal$,mask$,Field$

    vbsLookupCode = Chr(34) & "SY_TaxScheduleAll" & Chr(34)
    oScript.Execute("LookupCode$ = " & vbsLookupCode)

    vbsField = Chr(34) & "CO" & Chr(34) 'Using CO as my filter
    oScript.Execute("Field$ = " & vbsField)

    sCmd="CALL "+Chr(34)+"SY_Lookup.m4p;Called"+Chr(34)+",LookupCode$,Status,$$,startVal$,mask$,Field$"
    oScript.Execute(sCmd)

    rtnSelected = ""
    rtnSelected = oScript.Evaluate("Field$")
    sMsg = "Value selected from Lookup by Dan the Man = " & rtnSelected
    retMsg = oSession.AsObject(oSession.UI).MessageBox("", sMsg)



    ------------------------------
    Alnoor Cassim

    Accounting Systems, Inc. (ASI)
    Email: alnoor@asifocus.com
    Orange County, CA
    ------------------------------



  • 7.  RE: Has anyone been able to filter a UDF lookup validated w/UDT

    Posted 03-31-2020 17:32
    Edited by Dan Burleson 03-31-2020 23:35
    Works like a charm! DAMN you are good!!!


    ------------------------------
    Dan Burleson
    Software Consultant
    Connex Software
    Corvallis OR
    541-224-6642
    ------------------------------