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
End Sub

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


iruser said…
Can the code only be active if the buyer id field is empty? i.e. another user comes to do something to the po, tabs through the buyer id field and it changes to their ID. We'd rather it stay the same once populated.

Popular posts from this blog

Power Apps - Application Monitoring with Azure Application Insights

DBMS: 12 Microsoft Dynamics GP: 0 error when updating to Microsoft Dynamics GP 2013 R2

eConnect Integration Service for Microsoft Dynamics GP 2010