Open Forum

Expand all | Collapse all

VSTools for Dynamics GP - Procedures

  • 1.  VSTools for Dynamics GP - Procedures

    SILVER CONTRIBUTOR
    Posted Apr 23, 2019 05:14 PM
    Hi,
    I am pretty well familiar for developing under Visual Studio and bringing some customizations in Dynamics GP existing forms and windows.

    Whether it is for adding actions after buttons click, field enter, field exit, etc...
    BUT, there is also classes available under Dynamics.Procedures that looks interesting such as Dynamics.Procedures.SopPostInit or Dynamics.Procedures.SopPostTrxFinish

    One thing I never found under customizing for Dynamics GP is how to attach an event handler that would happen before or after a procedure instead of attaching to a form or window event handler.

    Example : If I would like to code something after the posting of an invoice, we know that you can post an invoice thru the Sales Entry window directly (without using a batch) -AND- you can use the "Sales Batch" window -AND- you can do it thru the Series Post window.

    So, I am wondering, are these class available only for "invoking" (in other words "starting") the posting or any other procedures, or is there a way to attach an event handler to such procedure so that, whenever it occurs under GP, the code would be called ?

    And if someone knows about these more in deep, if there is documentation on it, other than the few pages offered by the SDK, it would really be great to hear :)

    Maybe other would know ? @Steve Endow, @David Musgrave, @Mariano Gomez ?

    Thanks !​​​

    ------------------------------
    Luc St-Yves
    Business Analyst
    Co-Leader GPUG - Montreal chapter
    Humanware Technologies
    Drummondville QC
    ------------------------------


  • 2.  RE: VSTools for Dynamics GP - Procedures

    TOP CONTRIBUTOR
    Posted Apr 23, 2019 05:24 PM
    Edited by Steve Endow Apr 23, 2019 05:52 PM
    Hi Luc,

    Interesting question.

    Just to confirm I understand, you are asking if VS Tools has a "Before Procedure" / "After Procedure" option for Dex procedures or functions, or perhaps an option to have an Event Handler on a Dex procedure or function? Perhaps like a .NET delegate?

    I don't think I've seen anything like that in VS Tools, but @David Musgrave probably has a definitive answer or alternative options / workarounds.

    @Andrew Dean - Any experience with this during Post Master development?


    ------------------------------
    Steve Endow, Microsoft MVP
    Precipio Services
    Los Angeles, CA
    steveendow (at) gmail (dot) com
    ------------------------------



  • 3.  RE: VSTools for Dynamics GP - Procedures

    SILVER CONTRIBUTOR
    Posted Apr 23, 2019 05:57 PM
    You are correct Steve, I am looking for something similar to what we commonly do by developing event handlers after save of records or click of buttons in Dynamics GP windows, such as :
    Dim frmSOPOrderForm As Microsoft.Dexterity.Applications.DynamicsDictionary.SopEntryForm
    [...]
    AddHandler frmSOPOrderForm.SopEntry.SaveRecord.ValidateBeforeOriginal, AddressOf frmSOPOrderForm.SOPOrderBeforeSave
    AddHandler frmSOPOrderForm.SopEntry.SaveRecord.ValidateAfterOriginal, AddressOf SOPOrderAfterSave


    But instead of an handler on the window, we would be attaching to the Posting of an invoice action (procedure)...

    ------------------------------
    Luc St-Yves
    Business Analyst
    Co-Leader GPUG - Montreal chapter
    Humanware Technologies
    Drummondville QC
    ------------------------------



  • 4.  RE: VSTools for Dynamics GP - Procedures

    GPUG ALL STAR
    Posted Apr 23, 2019 07:33 PM
    @Luc St-Yves

    Yes, you can trigger before or after most of the functions and procedures (both global and form level) in any dictionary in GP. You have access to the parameters and can even change out parameters in the AfterInvoke event.

    You don't have access to some scripts as VSTools does not support anonymous and optional parameters and some complex data types.

    Use script logging (use GP Power Tools or manually) to capture script names to find the best location to register your events. For posting there is often a single script that is eventually called from transaction level, batch level, series post and master post that you can use to capture the post event for a transaction or batch.

    The trick is finding the best location so that a single event can be used.  Like using (L) Temp Control Number, Display Existing Record and Save Record for opening, displaying and saving on windows.

    PS: I saved your article from the Developing for Dynamics GP blog.

    https://winthropdc.wordpress.com/2012/05/08/how-to-update-microsoft-dynamics-gp-visual-studio-tools-addins-on-a-live-system/

    David

    ------------------------------
    David Musgrave MVP, GPUG All-Star

    Managing Director
    Winthrop Development Consultants

    Perth, Western Australia

    http://www.winthropdc.com
    ------------------------------



  • 5.  RE: VSTools for Dynamics GP - Procedures

    SILVER CONTRIBUTOR
    Posted Apr 23, 2019 11:14 PM
    Thank you David !
    I was reading your post and scratching my head trying to find out what did I miss...  I tried several ways for declaring this Dynamics.SopPostWhatever...  Then I read your answer again and Tada !  The keyword here from your post is "Dynamics Dictonnary" !
    All this time I was close to it but just didn't use the right declare statement, using DynamicsDictonary !

    So I then changed my declare to :
    Dim PostingEvent As DynamicsDictionary.SopPostInitProcedure

    And voila :


    I can see the Before and After events !

    Thank you so much.  This is going to solve so many headaches I was having working around the natural way of doing such handler :)

    P.S. : Isn't it surprising that this Mediafire link still works after so many years ;)

    ------------------------------
    Luc St-Yves
    Business Analyst
    Co-Leader GPUG - Montreal chapter
    Humanware Technologies
    Drummondville QC
    ------------------------------



  • 6.  RE: VSTools for Dynamics GP - Procedures

    SILVER CONTRIBUTOR
    Posted Apr 23, 2019 11:32 PM
    Woops, I shouted my joy too fast...

    @David Musgrave, would you be kind enough to give a little example on how to attach the handler to a DynamicsDictionar procedure, such as SopPostInitProcedure ?​​

    ------------------------------
    Luc St-Yves
    Business Analyst
    Co-Leader GPUG - Montreal chapter
    Humanware Technologies
    Drummondville QC
    ------------------------------



  • 7.  RE: VSTools for Dynamics GP - Procedures

    SILVER CONTRIBUTOR
    Posted Apr 24, 2019 11:36 AM
    @David Musgrave, you are my hero.  If I ever go to Australia, I owe you to wash your car (wait... did I just say that ?  Get your iPhone ready for a picture of it ;))

    I have finally been able to do it and now, with your advises, I manage to do it on any action events :)

    For others who would stumble into it, here is how I do it :
    1) Find out where to place your trigger on the right action by doing a script log using GP Power Tools as David suggest.
       This will gives you something like :

    2) Declare the event using its type contained in DynamicsDictionary, then link your definition to the Global Procedures contained under Dynamics class :
    Dim PostingEvent As DynamicsDictionary.SopTrxUpdatePostingStatusProcedure
    [...]
    Pay attention to the type of parameter for the event...

    3) Capture the event parameter using debug :

    You can now customize any operation you want upon Actions performed under Dynamics GP, such as the posting of an invoice :)

    Cheers !

    ------------------------------
    Luc St-Yves
    Business Analyst
    Co-Leader GPUG - Montreal chapter
    Humanware Technologies
    Drummondville QC
    ------------------------------



  • 8.  RE: VSTools for Dynamics GP - Procedures

    GPUG ALL STAR
    Posted Apr 24, 2019 07:39 PM
    @Luc St-Yves

    Glad you were able to get it sorted. This should open up a vast array of customisation opportunities for you.

    Regards

    David

    ------------------------------
    David Musgrave MVP, GPUG All-Star

    Managing Director
    Winthrop Development Consultants

    Perth, Western Australia

    http://www.winthropdc.com
    ------------------------------



If you've found this thread useful, dive deeper into User Group community content by role