By now you may have painfully noticed that all the SOP Entry screen buttons have disappeared and replaced by a graceful Actions button drop-down list. That's cool! Some may say. Less clutter! Others may yell. Yeah, right! But, for you the developer, this means that you are faced with upgrading all the customizations that depended on the Save, Delete, Void, Post, Transfer, and Purchase buttons to manage the new Actions button and spend a few more hours testing.
Approach
To make the changes to your customization code you must use the ActionButton.Value method to find the value of the chosen action (Save, Delete, etc.), however, life is not so simple as this window behaves differently based on the SOP document type, this is, the list of items in the Action button changes, depending on the type of SOP document selected by the user. For instance, assume you wanted to trap for the Delete action. When the document type is Fulfillment Order, choosing Delete causes ActionButton.Value property to be 3.
For a Back Order, choosing Delete causes ActionButton.Value property to be 4. Your VBA customization must now include the TypeTypeID field in the project so its value can be referenced. This is a sample code to test this -- the first message boxes displays the value that needs to be watched in the document type and action drop-downs
' Created by Mariano Gomez, MVP
' This code is provided "as is". No warranties express or implied
'
Private Sub ActionButton_AfterUserChanged()
'Which option was chosen?
MsgBox "Document type: " + TypeTypeID.Value
MsgBox "Action value: " + ActionButton.Value
If (TypeTypeID.Value = 6) And (ActionButton.Value = 4) Then
MsgBox ("Delete was chosen for a Back Order")
End If
End Sub
NOTE: The above sample assumes a basic customization. If you have several actions implemented for each document type this may not be an effective approach. Please read below.
Hope this helps in alleviating the transition.
UPDATE - 10/16/2008
David Musgrave just released a new article that details all the key points of working with the new SOP Action button while providing great samples to follow. Be sure to visit his site!
This method uses pass-thru sanScript in VBA by referencing the Dynamics Continuum Integration Library to use the same Dexterity method exposed by David to retrieve the value selected regardless of the document type. That value can be stored in the DUOS and retrieved to execute an action.
' Created by Mariano Gomez, MVP
' Code is provided "as is". No warranties express or implied
' 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
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
' Do your thing here
MsgBox ActionValue
End Sub
NOTE: This customization uses a method of calling pass-thru sanScript that is not supported by Microsoft.
Until next post!
MG.-
Mariano Gomez, MIS, MCP, PMP
Maximum Global Business, LLC
http://www.maximumglobalbusiness.com/
3 comments:
hello this is Hany ,
I am facing the same Problem Now in my upgrade , i tried the same idea as the Typetypeid and Action button.value . But i have more than one Case , When the order is printed , Delete button Don't Show , When it is not printed Print button has the index=4.
Same thing in the invoice case. there are more than one case that the Delete Button Change Index in the Same TypetypeID.
Is there any Solution For it .???
Hani,
Thanks for your inquiry! I am afraid you will have to painstakingly go through each of your customizations and make the changes manually as there is no automated way to do this.
The article only served as a guide on how to identify and perform the changes based on the actions.
Best regards,
MG.-
Mariano Gomez, MIS, MVP, MCP, PMP
Maximum Global Business, LLC
http://www.maximumglobalbusiness.com
Is there a way to access the actions butoon from .Net. I can't ssem to do that. I'm using SDK 10.0
Thanks
Noha
Post a Comment