Upgrading SOP Entry VBA Customizations from Dynamics GP 9.0 to Dynamics GP 10.0


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/

Comments

Anonymous said…
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 .???
Mariano Gomez said…
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
omyousuf said…
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
Unknown said…
Hi! This is my first post. I'm sorry for my english I don't write much well.
I have this sanscript code

enable command cmdVBAAddFields

On GP 9 this code enable on Customization Tool "Add VBA Fields option" although the registred product serial numbers not allow for dafault. On GP2010 this command not work for all Customization Tool Options
Mariano Gomez said…
@Rodrigo:
No entiendo tu pregunta. Por favor, escribe en Español.

MG.-
Yash Thakkar said…
Hi All,



I'm customizing "Sales Transaction Entry" screen in GP 2010. I'm facing wired issue in this while customizing this in VBA code.



There is a one drop down in this screen called "Actions" and it contains values like Transfer, Void, Copy, Post etc.

when any user clicks and select any of the option, i want to identify that text in VBA code behind.

For eg. If any use clicks on Actions and select Void, i want to get "VOID" in code behind. As of now i m getting a value but its in numerical order like 1,2.3...and so on. It means if any user clicks on Void option and void option is on 2nd place, i will get value 2 but not actual text Void...and i want actual text Void.



Is there any solution for this issue ?



Thanks in advance...



~Yash~
Mariano Gomez said…
@Yash,

Yes, you must have missed the entire article. This is precisely what this article is about. Take a look at the content after the Update 10/16/2008 section.

Popular posts from this blog

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

Cannot insert the value NULL into column 'CONTACT' error when clicking on Items List in Navigation Pane

How to uninstall Microsoft Dynamics GP 10.0 if you cannot uninstall it by using the "Add or Remove Programs" feature