21 February, 2009
How to make PO field required for specific customer
This requirement came up last week and after Mariano explained how to do it, I went ahead and did it... for fun. Sick, I know.
I posted an example of using the DUOS a couple of year ago and used that, with very few tweaks, after using Modifier to add a Check Box control to the Customer Maintenance window to store the RequiredPO flag in the DUOS (SY90000) as Mariano suggested. If you have problems converting that example to this scenario let me know and I will e-mail you the code.
After that, all you have to do is add the Sales Transaction Entry Window and the Customer ID and Customer PO Fields on that window to your Visual Basic Project. Open the VB Editor and add this code to the SalesTransactionEntry (Window) to make the Customer PO field required for selected customers:
Dim Msg, Style, Title, Help, Ctxt, Response, MyString, Default
Dim ItemCollection As DUOSObjects
Dim ItemObject As DUOSObject
Private Sub CustomerID_Changed()
On Error GoTo Proc_Error:
Set ItemCollection = DUOSObjectsGet("Customer")
If CustomerID.Empty = False Then
Set ItemObject = ItemCollection(CustomerID)
If ItemObject.Properties("RequirePO") = "1" Then
CustomerPONumber.Required = True
CustomerPONumber.Required = False
Proc_Error: MsgBox Error$ & " " & Error, vbOKOnly, "CustomerID_Changed"