Sage 100 Advanced 2018. I have a script designed to fire on AR Invoice Header PreWrite: If a BillTo account is specified in Invoice Header it should confirm the checkbox UDF_BTST is checked in AR_Customer, and if not should displays a message reminding the user to check the box.
This script triggers and works correctly when entering a single invoice manually. It also fires as desired, but does not work correctly, when the invoice is being generated using Repetitive Invoice Selection: then the message appears for EVERY invoice where a Bill-To Customer number exists in RI Entry, whether or not the UDF_BTST checkbox in AR_Customer is checked.
I believe the problem is that the GetChildHandle call is not working during the Repetitive Invoice Selection process, though it does work during manual invoice entry. Can someone confirm that? I'd like to avoid having to create another business object hundreds of times during the invoice selection process, which is why I want to use GetChildHandle if possible.
Here is a watered down version of the script should anyone care to test:
'Check to see if BTST feature is used
oCust = 0
sINBT = "" 'Invoice Header Bill-To Customer Number, if exists
sARBT = "" 'AR_Customer UDF_BTST
retVal = oBusObj.GetValue("BillToCustomerNo$", sINBT)
'If a Bill-To Customer Number has been entered, confirm UDF_BTST checkbox value
If sINBT <> "" then
SET oCust = oBusObj.AsObject(oBusObj.GetChildHandle("CustomerNo"))
retVal = oCust.GetValue("UDF_BTST$", sARBT)
'if UDF_BTST checkbox isn't checked, display message to user
If sARBT <> "Y" then
sMsg = "IMPORTANT: Please open AR Customer Maintenance for " & sDiv & "-" & sCustNo & ", go to the Invoice tab "
sMsg = sMsg & "and CHECK the -BT Used?- box (on the right) to indicate the BT/ST feature has been used, "
sMsg = sMsg & "to remind others to look at Invoice History Inquiry when reviewing this account."
retMsg = oSession.AsObject(oSession.UI).MessageBox("",sMsg,"Style=OK")
End If
End If