I'm trying to add an MS Script button to the SO Invoice Data Entry panel. In the script I need to access the LOCAL cCurrentPaymentTypeMethod$ property inherited from Class SO_CommonEntry_UI. Can this be done and, if so, how would it be coded?
I'm trying to add an MS Script button to the SO Invoice Data Entry panel. In the script I need to access the LOCAL cCurrentPaymentTypeMethod$ property inherited from Class SO_CommonEntry_UI. Can this be done and, if so, how would it be coded?
ehx there are MANY ways and I would actually consider getting the inherited VAR from SO_CommonEntry_UI the least preferred. Only because the internal c VARs can change how they behave over versions and…
Your button should be set to "Execute Script on Server" instead of the default "Execute Script on Client".
That did it, thanks! We are running Sage 100 Advanced ERP 2015 (soon to be upgrading to 2017). Do all scripts we write need to be set to "Execute Script on Server"? If not, when would we sele…
ehx there are MANY ways and I would actually consider getting the inherited VAR from SO_CommonEntry_UI the least preferred. Only because the internal c VARs can change how they behave over versions and sometimes they don't abstract into specific places within the main object. Dealing with this is normal for M/D work but for scripting I recommend trying in this order:
I assume the intention is to first click on PTotals / PTotalsW before clicking your button. Also that the Payment Type has already been either entered by the user, defaulted in from the order, or defaulted in from the customer record (if a one-step invoice that has no Order No). It just can't be blank
1) Preferred: Take advantage of child object SO_InvoicePayment_bus which has a property for this already:
Set oPaymentObj = oBusObj.AsObject(oBusObj.PaymentObj)
sPTM = oPaymentObj.PaymentTypeMethod
sMsg = "1. Current Payment Type Method$ = " & sPTM
retMsg = oSession.AsObject(oSession.UI).MessageBox("", sMsg)
2) Take advantage of the data source (referenced via a child handle)
Set oPayment = oBusObj.AsObject(oBusObj.GetChildHandle("PaymentType"))
sPaymentType = "" : sPTM = ""
retVal = oBusObj.GetValue("PaymentType$", sPaymentType)
FoundPymt = oPayment.Find(sPaymentType)
If FoundPymt Then
retVal = oPayment.GetValue("PaymentMethod$", sPTM)
sMsg = "2. Current Payment Type Method = " & sPTM
retMsg = oSession.AsObject(oSession.UI).MessageBox("", sMsg)
End If
3) Use UDF Maintenance to Source the PaymentMethod from AR_PaymentType and place on the screen
It's SAME as No 2 except use UDF Maintenance on SO Invoice Header to create a UDF called PymtMethod. Choose Business Object UDF. instead of Manual. The Data Source will be PaymentType (which points to AR_PaymentType table) then select column PaymentMethod. Place the UDF on PTotals / PTotalsW near the Payment Type. Now going fwd as soon as a Payment Type is entered or defaulted in, so will the UDF. Your code is shortened to just:
sPymtMethod = ""
retVal = oBusObj.GetValue("UDF_PYMTMETHOD$", sPymtMethod)
4) Get the internal VAR cCurrentPaymentTypeMethod from SO_CommonEntry_UI.
cCPTM = ""
retVal = oUIObj.GetValue("cCurrentPaymentTypeMethod$", cCPTM)
sMsg = "4. cCurrentPaymentTypeMethod$ = " & cCPTM
retMsg = oSession.AsObject(oSession.UI).MessageBox("", sMsg)
ehx there are MANY ways and I would actually consider getting the inherited VAR from SO_CommonEntry_UI the least preferred. Only because the internal c VARs can change how they behave over versions and sometimes they don't abstract into specific places within the main object. Dealing with this is normal for M/D work but for scripting I recommend trying in this order:
I assume the intention is to first click on PTotals / PTotalsW before clicking your button. Also that the Payment Type has already been either entered by the user, defaulted in from the order, or defaulted in from the customer record (if a one-step invoice that has no Order No). It just can't be blank
1) Preferred: Take advantage of child object SO_InvoicePayment_bus which has a property for this already:
Set oPaymentObj = oBusObj.AsObject(oBusObj.PaymentObj)
sPTM = oPaymentObj.PaymentTypeMethod
sMsg = "1. Current Payment Type Method$ = " & sPTM
retMsg = oSession.AsObject(oSession.UI).MessageBox("", sMsg)
2) Take advantage of the data source (referenced via a child handle)
Set oPayment = oBusObj.AsObject(oBusObj.GetChildHandle("PaymentType"))
sPaymentType = "" : sPTM = ""
retVal = oBusObj.GetValue("PaymentType$", sPaymentType)
FoundPymt = oPayment.Find(sPaymentType)
If FoundPymt Then
retVal = oPayment.GetValue("PaymentMethod$", sPTM)
sMsg = "2. Current Payment Type Method = " & sPTM
retMsg = oSession.AsObject(oSession.UI).MessageBox("", sMsg)
End If
3) Use UDF Maintenance to Source the PaymentMethod from AR_PaymentType and place on the screen
It's SAME as No 2 except use UDF Maintenance on SO Invoice Header to create a UDF called PymtMethod. Choose Business Object UDF. instead of Manual. The Data Source will be PaymentType (which points to AR_PaymentType table) then select column PaymentMethod. Place the UDF on PTotals / PTotalsW near the Payment Type. Now going fwd as soon as a Payment Type is entered or defaulted in, so will the UDF. Your code is shortened to just:
sPymtMethod = ""
retVal = oBusObj.GetValue("UDF_PYMTMETHOD$", sPymtMethod)
4) Get the internal VAR cCurrentPaymentTypeMethod from SO_CommonEntry_UI.
cCPTM = ""
retVal = oUIObj.GetValue("cCurrentPaymentTypeMethod$", cCPTM)
sMsg = "4. cCurrentPaymentTypeMethod$ = " & cCPTM
retMsg = oSession.AsObject(oSession.UI).MessageBox("", sMsg)
Thanks for your reply but I'm still having trouble. I've tried three of the four options but get the error #424 "Object required:" in all cases - case 1 and 2 'oBusObj'; case 4 'oUIObj'. Also, I would like to place the button on the CCard, not Totals tab. How would that impact the script?
Maybe you don't have Allow External Access box checked for this company code in Library Master / Main / Company Maintenance. Running from Credit Card tab should be fine as long as there is a Payment Type in Totals.
External Access is Enabled in Library Master. Any other suggestions?
Your button should be set to "Execute Script on Server" instead of the default "Execute Script on Client".
That did it, thanks! We are running Sage 100 Advanced ERP 2015 (soon to be upgrading to 2017). Do all scripts we write need to be set to "Execute Script on Server"? If not, when would we select "Execute Script on Client"?
Server: access to business objects
Client: access to user interface / workstation
*Community Hub is the new name for Sage City