What is the best way to script pulling in desired values when trying to link out to a one-to-many table? I am trying to override what standard Sales Order Entry does when bringing in the AliasItemNo for a line and instead look for a General Alias with a Description of ""UPC CODE"". But an item can have many aliases, so how do I search for and pull in only the one that I want? I started with the script below, but am stumped. I found an old post by Alnoor back in 2011 that mentions copying data to a shadow table and then linking from there instead. Is that the best (or only) option at this point would be to populate a Shadow UDT of only these specific aliases and pull from there into the Lines? Thanks in advance for any guidance!
'Reset Variables
sItemCode = """" : sItemType = """" : sAliasItem = """" : sAliasDesc = """"
oAlias = """" : retval = 0
retVal = oBusObj.GetValue(""ItemCode$"", sItemCode)
retVal = oBusObj.GetValue(""ItemType$"", sItemType)
if sItemType <> ""1"" then
exit sub
end if
'Set IM_AliasItem Object and Primary Key
Set oAlias = oSession.AsObject(oSession.GetObject(""IM_AliasItem_bus""))
retVal = oAlias.SetKeyValue(""ItemCode$"", sItemCode)
retVal = oAlias.Find()
if retval = 1 then
retval = oAlias.GetValue(""AliasItemNo$"", sAliasItem)
retval = oAlias.GetValue(""AliasItemDesc$"", sAliasDesc)
if sAliasDesc = ""UPC CODE"" then
retval = oBusObj.SetValue(""AliasItemNo$"", sAliasItem)
end if
end if