I have a script for Item Maintenance that is connecting to Item Warehouse, summing up QtyOnHand and then writing it to a UDF on the Main Panel. The script works when I can get it to run, but I am having trouble figuring out which Event I can associate the script to so it will run correctly.
When I tried launching the script with CI_Item Master on Event Table Post-Read, something "errors" and the Item Selected won't load. Instead once I select an Item I just get a blank PMain table and the options to Accept, Delete, and Cancel become available. It seems to me like this is where I should have the scripted launched from, but since the table field are all showing up blank, clearly my script is causing an issue here.
When I tried to hook it to use the customizer selection for the PMain panel for Inventory Management -> Item Maintenance on the trigger Event Panel - PostLoad the script works fine, but it doesn't load at the same time that the item is first selected. I have to switch to any other tab and then back to Main to get the Script to run.
What I would like to do, is have the script run as soon as an Item is Selected or changed by the "First, Previous, Next, Last" buttons on the Dmain Panel and see my UDF field get populated at the same time as all the details on Pmain Panel get loaded. It seems like this shouldn't be that hard, but I have 0 experience with Sage and very little with scripting.
Thanks in Advance
Script Below since it may be the reason for a blank table
oIW = 0
retvalue = 0
strStagedINV = ""
strFilterIC = ""
TotUnits = 0
OnHandUnits = 0
strItemCode=""
oIWLines=""
'''''''''''''
'Get Item Code
retvalue = oBusObj.GetValue("ItemCode",strItemCode)
'retvalue = oScript.DebugPrint("Got To Here " & strItemCode)
'''''Get ItemWarehouse as Business Object
oIW = oSession.GetObject("IM_ItemWarehouse_bus")
if oIW <> 0 then
SET oIW = oSession.AsObject(oIW)
' retvalue = oScript.DebugPrint("Got Inside the oIW")
end if
'retvalue = oScript.DebugPrint("oIW should be loaded")
'''''''Establish ItemCode as Search Term for ItemWarehouse
retvalue = oIW.SetBrowseIndex(Itemcode, "")
retvalue = oIW.SetBrowseFilter(ItemCode & "" & strItemCode)
'''''Cycle through Warehouse for Item summing totals
retvalue = oIW.MoveFirst()
while not (cBool(oIW.EOF))
retvalue = oIW.GetValues("ItemCode,WarehouseCode,BinLocation,QuantityOnHand,QuantityOnPurchaseOrder,QuantityOnSalesOrder",oIWLines)
' retvalue = oScript.DebugPrint(oIWLines)
retvalue = oIW.GetValue("QuantityOnHand",OnHandUnits)
retvalue = oIW.GetValue("ItemCode",strFilterIC)
'Had to add an If statement, because the filter is returning items that contain strItemCode instead of = to
if (strItemCode = strFilterIC) then
TotUnits = TotUnits + OnHandUnits
end if
' retvalue = oScript.DebugPrint(OnHandUnits & " " & TotUnits)
oIW.MoveNext
wend
'retvalue = oScript.DebugPrint("On Hand " & OnHandUnits & " Total " & TotUnits)
strStagedINV = TotUnits
retvalue = oBusObj.SetValue("UDF_STAGEDINV",strStagedINV)
oBusObj.Write()
'msgbox "Reached Script End"