InvokeLookup return value question

SOLVED
I am trying to write a script that allows a user to press a button on the SO lines screen to call up the alias item numbers lookup, select a value, and then update a value on the line with a UDF from the selected alias item number. I am able to get the lookup to load, but I'm having an issue with the lookup only returning the itemcode rather then the full key for the alias item so I am unable to query the alias item object successfully. Is there anyway to control 
In the example below, if I press the button with a line with 1001-HON-H252 as the itemcode, I get the correct list of alias items in the lookup, but they all return just 1001-HON-H252 rather then 1001-HON-H252 +AliasItemNo+Type etc....
Is there a way to control what gets returned?
sLineKey = ""
sComment = ""
sItemCode = ""
sAliasItemKey = ""
sItemSeed = ""

set oLines = oBusObj.asObject(oBusObj.Lines)
r = oLines.GetValue("LineKey$", sLineKey)
sEditKey = oLines.GetEditKey(sLineKey)
r = oLines.EditLine(sEditKey)

r = oLines.GetValue("ItemCode$",sItemCode)
itemLength = oSession.AsObject(oSession.FileObj).GetColumnLength("SO_SalesOrderDetail""ItemCode$")
sItemSeed = sItemCode + String(itemLength - Len(sItemCode), Chr(0))
r = oUIObj.InvokeLookup("IM_AliasItemItem",sAliasItemKey,sItemSeed)
msgbox(sAliasItemKey)
Set oAlias = oSession.AsObject(oSession.GetObject("IM_AliasItem_bus"))
r = oAlias.Find(sAliasItemKey)
msgbox(cstr(r))
Parents
  • 0

    Try using the "IM_AliasItemNumber" lookup instead of "IM_AliasItemItem" lookup.

    A brief test using "IM_AliasItemNumber" returned the alias+itemcode+type each separated by the SEP character (ASCII # 138).

    A brief test using "IM_AliasItemTypeNo" returned the alias+itemcode+type each separated by the NULL character (ASCII # 0).

    I could not get "IM_AliasItemItem" to even list any records so i could not test its returned value but i suspect it is returning the alias+itemcode+type each separated by the NULL character (ASCII # 0).

    Also, if you are only reading values from the alias table, you should use the "IM_AliasItem_Svc" object instead of the "IM_AliasItem_Bus" object.

    Another approach you could take is let the user use the standard Alias Item lookup button (ALT+G on the Lines tab in Sales Order Entry), this should populate the AliasItemNo field in SO_SalesOrderDetail, so you can either place your script on the post read (check for edit state equals 2) or the pre write of SO_SalesOrderDetail. I don't know for sure whether the post validate on AliasItemNo will fire when the alias item lookup is used. Depending on your version, i think 2018+, you might be able to use the post validate on ItemCode instead of the post read or pre write. If you use a script on one of these events, you would just need to use GetValue on the ItemCode and AliasItemNo fields and then use the browse filter to locate the record. You could try using the SetKeyValue method to set each part of the key and then use Find but if you refer to https://help-sage100.na.sage.com/2019/FLOR/#File_Layouts/Inventory_Management/IM_AliasItem.htm%3FTocPath%3DFile%2520Layouts%7CInventory%2520Management%7C_____4, you'll see even the primary index still includes the customer number and vendor number. You might be able to get away with just using SetKeyValue on the item code, alias item, type (being C), ar division, customer, ap division (equal to blank or ASCII # 0), and vendor (equal to blank or ASCII # 0) and then if Find doesn't return a 1, then use SetKeyValue on the item code, alias item, type (being G), ar division (equal to blank or ASCII # 0), customer (equal to blank or ASCII # 0), ap division (equal to blank or ASCII # 0), and vendor (equal to blank or ASCII # 0).

Reply
  • 0

    Try using the "IM_AliasItemNumber" lookup instead of "IM_AliasItemItem" lookup.

    A brief test using "IM_AliasItemNumber" returned the alias+itemcode+type each separated by the SEP character (ASCII # 138).

    A brief test using "IM_AliasItemTypeNo" returned the alias+itemcode+type each separated by the NULL character (ASCII # 0).

    I could not get "IM_AliasItemItem" to even list any records so i could not test its returned value but i suspect it is returning the alias+itemcode+type each separated by the NULL character (ASCII # 0).

    Also, if you are only reading values from the alias table, you should use the "IM_AliasItem_Svc" object instead of the "IM_AliasItem_Bus" object.

    Another approach you could take is let the user use the standard Alias Item lookup button (ALT+G on the Lines tab in Sales Order Entry), this should populate the AliasItemNo field in SO_SalesOrderDetail, so you can either place your script on the post read (check for edit state equals 2) or the pre write of SO_SalesOrderDetail. I don't know for sure whether the post validate on AliasItemNo will fire when the alias item lookup is used. Depending on your version, i think 2018+, you might be able to use the post validate on ItemCode instead of the post read or pre write. If you use a script on one of these events, you would just need to use GetValue on the ItemCode and AliasItemNo fields and then use the browse filter to locate the record. You could try using the SetKeyValue method to set each part of the key and then use Find but if you refer to https://help-sage100.na.sage.com/2019/FLOR/#File_Layouts/Inventory_Management/IM_AliasItem.htm%3FTocPath%3DFile%2520Layouts%7CInventory%2520Management%7C_____4, you'll see even the primary index still includes the customer number and vendor number. You might be able to get away with just using SetKeyValue on the item code, alias item, type (being C), ar division, customer, ap division (equal to blank or ASCII # 0), and vendor (equal to blank or ASCII # 0) and then if Find doesn't return a 1, then use SetKeyValue on the item code, alias item, type (being G), ar division (equal to blank or ASCII # 0), customer (equal to blank or ASCII # 0), ap division (equal to blank or ASCII # 0), and vendor (equal to blank or ASCII # 0).

Children
No Data