I'm new to scripting and having a little trouble. I'm trying to grab the primary vendor alias for an item from IM_AliasItem and put it into a UDF in CI_Item. This will probably be triggered on reading the item record, if that makes a difference, but I have it on a button right now for testing. The problem seems to be that because I am searching for a record with a partial key (i.e., I only have the record type, division, vendor, and item code, but not the alias itself) I am using SetBrowseFilter, but maybe I am not formatting it correctly. If I only search with the "Type/Division/Vendor" part of the key I get a result (the first record that matches that vendor - not what I'm looking for), but when I add the Item Code to the end I get no result. Here is my script:
'by PLW 6/26/18
'To write the primary vendor alias from IM_AliasItem into CI_Item UDF
retVal = 0
sPVendor = ""
sItemCode = ""
sDiv = ""
sAlias = ""
sPVAlias = ""
'retrieve the CI_Item info
retVal = oBusObj.GetValue("PrimaryVendorNo$", sPVendor)
retVal = oBusObj.GetValue("ItemCode$", sItemCode)
retVal = oBusObj.GetValue("APDivisionNo$", sDiv)
'bring in the IM_AliasItem table and search for the primary vendor alias
set oAliasItem = oSession.AsObject(oSession.GetObject("IM_AliasItem_bus"))
retVal = oAliasItem.SetBrowseIndex("KVENDORITEM","")
retVal = oAliasItem.SetBrowseFilter("V" & sDiv & sPVendor & sItemCode) <<<< when I add this, I get no result
retVal = oAliasItem.MoveNext()
'diagnostic message box
'sMsg = cstr(retVal) + " - " + oAliasItem.LastErrorMsg
'retMsg = oSession.AsObject(oSession.UI).MessageBox("", sMsg)
'assign the primary vendor code if found
If retVal = 1 then
retVal = oAliasItem.GetValue("AliasItemNo$", sPVAlias)
End If
'write to the UDF
retVal = oBusObj.SetValue("UDF_PR_VND_ITM_AL$", sPVAlias)
Any help would be greatly appreciated!