Every ERP organization is having different departments like finance, Inventory, Purchase & Human Resource etc. Each department is having their tasks to perform on daily basis. We as SL administrator need to provide the proper rights to every department. SL is having the access rights maintenance screen which is used to provide the access rights to every department by user wise and Group wise.
Microsoft Dynamics SL provides the security features by providing the sufficient access rights to the users. This security feature is used to protect our customization from unauthorized access.
We are going to discuss about the security of Microsoft Dynamics SL in this post.
Steps to customize the standard screen with locking feature.
- Go to Customize mode on contract maintenance screen.
- Press F7 to Visual Basic for Application Editor
- Go to Tools option and select the Project Properties
- Project Properties screen pops up and go to the protection tab.
- Checked the Lock project for viewing
- Set the password and confirm password option to protect the customization with password.
- Save the customization and reopen the screen.
We can do the customization with simple code. We have to write the code in Form Load event to protect the customization with password.
Private Sub Form1_Load()
Dim Security$, MessPrompt$, MessTitle$, Password$
Password = “test”
MessPrompt = “Enter password to open screen.”
MessTitle = “Password Required.”
Security = PasswordBox$(MessPrompt, MessTitle)
If Trim$(Security) <> “” Then
If LCase(Security) <> Password Then
MsgBox “Invalid Password.”, vbOKOnly, MessTitle
retval = ErrNoMess
Call Edit_Close
End If
Else
MsgBox “Password is required to open this screen.”, vbOKOnly, MessTitle
retval = ErrNoMess
Call Edit_Close
End If
End Sub
Also we’ll need to add a “VBATool_VBA” code module with the following code:
Public Declare Function PasswordBox Lib “sbltovba.dll” (ByVal szPrompt As String, Optional ByVal szTitle As String, Optional ByVal szDefault As String, Optional ByVal xPos As Long = -1, Optional ByVal yPos As Long = -1) As String
Public Declare Function GetField Lib “sbltovba.dll” (ByVal szString As String, ByVal iFieldNum As Integer, ByVal szSepChars As String) As String
Public Declare Function SetField Lib “sbltovba.dll” (ByVal szString As String, ByVal iFieldNum As Integer, ByVal szField As String, ByVal szSepChars As String) As String
Public Declare Function GetAccelerator Lib “sbltovba.dll” (ByVal szString As String) As String
Public Declare Function GetCaption Lib “sbltovba.dll” (ByVal szString As String) As String
Public Declare Function ConvertX Lib “sbltovba.dll” (ByVal xVal As Long, Optional ByVal lFlag As Long = 0) As Long
Public Declare Function ConvertY Lib “sbltovba.dll” (ByVal yVal As Long, Optional ByVal lFlag As Long = 0) As Long
Public Declare Function Clipboard_GetText Lib “sbltovba.dll” () As String
Public Declare Sub Clipboard_SetText Lib “sbltovba.dll” (ByVal szString As String)
Public Declare Function Clipboard_Clear Lib “sbltovba.dll” () As Boolean
Public Declare Function Clipboard_GetFormat Lib “sbltovba.dll” (ByVal iFormat As Integer) As Boolean.
The source code has given by Mark Ehelben who is my forum mate. He is the person who gave the work around on my issue. Thanks to Mark Ehelben.This post will be useful to developers who is working in Dynamics SL.