Open Item Customer Sales History By Period UI from Button Script - pass Customer

SOLVED

Experts,

I am using the button script below to open Customer History by Period from a Sales Order line (Sage has this button in Item Maintenance on the History tab). It works. It opens properly for the item. But there is a secondary selection criterion in the UI for the customer. Is there a way to automatically populate that (ideally as part of the Process method).

If that is not possible, then  I might have to work on one of these workarounds:

1) I could use InvokeChange on the ML_HISTORYCUSTOMER field. But my problem here is that the button is clicked in Sales Order Entry, so I am not sure how I would get a UI Object handle for the freshly opened IM_ItemCustomerHistoryByPeriod_UI.

2) I could use a StorageVar that I populate from the script below, and then I could read that var as part of a UI event script the IM_ItemCustomerHistoryByPeriod_UI. From there I can do the InvokeChange, and reset the StorageVar. Instead of a UI script, I could possibly also use a  Post-Read on the IM_ItemCustomerHistoryByPeriod

Any idea on how to pass the customer, or thoughts on my workarounds?

Thanks,

Bastian

oLines = 0 : sItem = "" : sItemType = ""

Set oLines = oBusObj.AsObject(oBusObj.Lines)
retVal = oLines.GetValue("ItemCode$",sItem)
retVal = oLines.GetValue("ItemType$",sItemType)

If sItemType = "1" Then
	oItemSalesHist = 0
	oItemSalesHist = oSession.GetObject("IM_ItemCustomerHistoryByPeriod_UI")

	If oItemSalesHist <> 0 Then
		Set oItemSalesHist = oSession.AsObject(oItemSalesHist)
		retVal = oItemSalesHist.Process(sItem)
	End if
End If