VBA Mod - Disable the Action Buttons in the SOP Transaction Entry window

Today's video is going to demonstrate a technique to disallow actions from the SOP  Transaction Entry window Action Button. We don't have the ability to enable/disable this button, so we'll do the next best thing and stop the action from completing.

 

This will be a VBA modification, that means that you have to have reg keys that allow you to make VBA modifications.

 

The solution that I'm going to offer is somewhat complcated, I'm not going to explain it in full because it would introduce a larger topic than we have time for… but the article that accompanies this video has a link to the author of the code. Our job here is to teach how to implement it.

Adding a Native Field

 Video

Code that accompanies the article:

' Created by Mariano Gomez, MVP
' Code is provided "as is". No warranties express or implied
  
Option Explicit
  
Dim ParamCollection As DUOSObjects
Dim ParamObject As DUOSObject
  
Private Sub ActionButton_BeforeUserChanged(KeepFocus As Boolean, CancelLogic As Boolean)
    ' Dim CompilerApp As New Dynamics.Application
    Dim CompilerApp As Object
      
    Dim CompilerMessage As String
    Dim CompilerError As Integer
    Dim CompilerCommand As String
    Dim ActionValue As Integer
      
    ActionValue = 0
      
    ' Initialize DUOS
    Set ParamCollection = DUOSObjectsGet("Param." & UCase(UserInfoGet.UserID))
    Set ParamObject = ParamCollection.Item("SOPEntryAction")
    ParamObject.Properties("ActionValue") = Str(ActionValue)
      
    CompilerCommand = CompilerCommand & "clear table SY_User_Object_Store; " & vbCrLf
    CompilerCommand = CompilerCommand & "'ObjectType' of table SY_User_Object_Store = """ & "Param." & UCase(UserInfoGet.UserID) & """; " & vbCrLf
    CompilerCommand = CompilerCommand & "'ObjectID' of table SY_User_Object_Store = """ & "SOPEntryAction" & """; " & vbCrLf
    CompilerCommand = CompilerCommand & "'PropertyName' of table SY_User_Object_Store = """ & "ActionValue" & """; " & vbCrLf
    CompilerCommand = CompilerCommand & "change table SY_User_Object_Store; " & vbCrLf
    CompilerCommand = CompilerCommand & "'PropertyValue' of table SY_User_Object_Store = str(itemdata('Action Button' of window SOP_Entry of form SOP_Entry, 'Action Button' of window SOP_Entry of form SOP_Entry)); " & vbCrLf
    CompilerCommand = CompilerCommand & "save table SY_User_Object_Store; " & vbCrLf
    CompilerCommand = CompilerCommand & "check error; " & vbCrLf
      
    ' Shows you the sanScript code to be executed -- comment out for your project
    'MsgBox CompilerCommand
      
    ' Execute SanScript
    Set CompilerApp = CreateObject("Dynamics.Application")
    CompilerError = CompilerApp.ExecuteSanscript(CompilerCommand, CompilerMessage)
    If CompilerError <> 0 Then
        MsgBox CompilerMessage
    Else
        ' Retrieve return values from DUOS
        Set ParamCollection = DUOSObjectsGet("Param." & UCase(UserInfoGet.UserID))
        Set ParamObject = ParamCollection.Item("SOPEntryAction")
        ActionValue = Val(ParamObject.Properties("ActionValue"))
        ParamCollection.Remove ("SOPEntryAction")
    End If
      
    Set CompilerApp = Nothing
      
    ' The Actions button will return the following values regardless of document
    ' type - these values are stored in the ActionValue variable
    ' 1 - ACTION_POST
    ' 2 - ACTION_TRANSFER
    ' 3 - ACTION_PURCHASE
    ' 4 - ACTION_CONFIRMPICK
    ' 5 - ACTION_CONFIRMPACK
    ' 6 - ACTION_CONFIRMSHIP
    ' 7 - ACTION_COPY
    ' 8 - ACTION_DELETE
    ' 9 - ACTION_VOID
    If ActionValue = 8 Then
        CancelLogic = True
        MsgBox ("Delete Not Allowed")
    End If
      
      
End Sub

RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences