Automating Buyer ID field entry with logged in User ID in the PO Entry window in Microsoft Dynamics GP
Here is another very common request: how can the Buyer ID field entry be automated with the user ID currently logged into Microsoft Dynamics GP? This is certainly an important control feature in environments where security is key to auditors and systems administrators alike.
A simple VBA script can take care of this issue, as follows:
1) Add the Purchase Order Entry screen and the Buyer ID field to Visual Basic
2) Open the Visual Basic Editor
3) Locate Microsoft_Dynamics_GP > Microsoft Dynamics GP Objects
4) Double-click on the PurchaseOrderEntry (Window) object
5) Add the following code in the editor
' Created by Mariano Gomez, MVP
' Code is provided "AS IS". No warranties express or implied
Private Sub BuyerID_BeforeGotFocus(CancelLogic As Boolean)
Dim usrinfObj As UserInfo
Dim usrID As String
Set usrinfObj = VbaGlobal.UserInfoGet()
usrID = usrinfObj.UserID
BuyerID = usrID
I know what you are thinking... this script could use some enhancements:
1) You can add additional code to check whether the buyer ID already exist in the database prior to assigning the usrinfObj.UserID content to the usrID variable
2) Of course, all the ramifications of the non-existance of the buyer ID that goes along with programming best practices and application security.
Until next post!
Mariano Gomez, MIS, MCP, PMP
Maximum Global Business, LLC