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.comOrange County, CA
------------------------------
Original Message:
Sent: 03-31-2020 10:56
From: Alnoor Cassim
Subject: Has anyone been able to filter a UDF lookup validated w/UDT
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
------------------------------
Original Message:
Sent: 03-31-2020 04:23
From: Dan Burleson
Subject: Has anyone been able to filter a UDF lookup validated w/UDT
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_ProductLineLookupCode = "IMUDTSUBPRODLINE"'One way to get LookupCode is by watching variable Control$ when clicking the Customer Contact Lookup buttonrtnVal = ""'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: " & rtnValElse MsgBox "Using ProductLine: '" & sProductLine & "' InvokeLookup returned nothing: " & rtnValEnd If
------------------------------
Dan Burleson
Software Consultant
Connex Software
Corvallis OR
541-224-6642
Original Message:
Sent: 03-27-2020 12:30
From: Alnoor Cassim
Subject: Has anyone been able to filter a UDF lookup validated w/UDT
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