Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

How to Execute a Dexterity Procedure Programmatically

(1) ShareShare
ReportReport
Posted on by 5

How can I execute a Dexterity procedure programmatically?

Goal:

I want to reset a user password within GP 2018 programmatically.  For the purposes of any discussion we have moving forward, programmatically does NOT refer to the following:

  1. Clicking buttons in a user interface manually, particularly after launching Dynamics.exe
  2. Running a Great Plains 2018 macro

Background:

  • The only possible supported solution for what I am trying to achieve I believe must rely on Dexterity.  I have no idea how to execute a Dexterity procedure programmatically, so this might be impossible.
  • I have a Dexterity script (Dynamics procedure) defined which is very simple—it resets a GP user password via Login_AlterLogin().  It has no parameters and is based on the examples provided in Dex.chm help file.
  • To deploy and use this Dexterity script I have done the following:
    • Created a dictionary (dev.dic)
    • Created and compiled the Dexterity script within my editable dictionary (dev.dic)
    • Created a CNK file (dev.cnk)
    • Launched GP and performed unchunking
    • Generated a DLL using Dag.exe (Application.Dev.dll)
    • Adding the assembly into my Visual Studio project (Application.Dev assembly added to a C# console app)
    • Attempted to Invoke the procedure (Dexterity.Applications.Dev.Procedures.Dev.Invoke();).
  • My C# app attempts to make a GP connection before invoking the procedure, as shown below.
  • I have validated that my GPConnection is successfully connecting (gpConn.ReturnCode = 1).

Code (C#):

            SqlConnection sqlConn = new SqlConnection();
            sqlConn.ConnectionString = string.Format("Database = {0}", "RST");

            int resp = GPConnection.Startup();
            GPConnection gpConn = new GPConnection();
            gpConn.Init("CompanyName", "1233_special_keys_for_vstools_5678");
            gpConn.Connect(sqlConn, "DEV1", "sa", "Secret_pwd678");

            Microsoft.Dexterity.Applications.Dev.Procedures.Dev.Invoke();
            resp = GPConnection.Shutdown();

Error:

System.TypeInitializationException

  HResult=0x80131534

  Message=The type initializer for 'Microsoft.Dexterity.Applications.root' threw an exception.

  Source=Application.Dev

  StackTrace:

   at Microsoft.Dexterity.Applications.DevDictionary.DevProcedure.get_WrappedScript()

   at Microsoft.Dexterity.Applications.DevDictionary.DevProcedure.Invoke()

   at gp_test.Program.MakeConnection() in C:\Users\administrator.ROCKSOLID\source\repos\gp_test\gp_test\Program.cs:line 27

   at gp_test.Program.Main(String[] args) in C:\Users\administrator.ROCKSOLID\source\repos\gp_test\gp_test\Program.cs:line 11

Inner Exception 1:

NullReferenceException: Object reference not set to an instance of an object.

Categories:
  • Edwin Graham Profile Picture
    Edwin Graham 15 on at
    RE: How to Execute a Dexterity Procedure Programmatically

    Hi Jocelyn,

    Good old Continuum - that took me back a fair few years.

    As far as I can tell, Continuum is the grandfather of VSTGP, and yes, it requires a GP instance to be logged in for the code to work.

    You can have a stand-alone C# program (or Continuum) which will hook into the running Dynamics.exe - but if you attempt to execute code without Dynamics.exe running, you will get the old message "Object reference not set to an instance of an object".

    Thanks,

    Ed

  • Embrionix Profile Picture
    Embrionix 5 on at
    RE: How to Execute a Dexterity Procedure Programmatically

    Hi Edwin,

    Am I mistaken or could Continuum not allow a stand-alone application to call Dexterity code?

    In particular through the ExecuteSanScript method, passing code along the lines of "call <procedureName>{, params}".

    Cheers,

    JG

  • Edwin Graham Profile Picture
    Edwin Graham 15 on at
    RE: How to Execute a Dexterity Procedure Programmatically

    Hi There,

    The VS part of the SDK was created so you could run C# / VB .NET code within the context of a running Dynamics GP instance using an Add-in.

    I am going to assume you want a stand-alone C# application which would execute a piece of Dexterity code.

    Unfortunately this is not going to happen, and is probably not even possible without GP running in the first place (in which case you would use a VSTDGP add-in).

    Your "GP Connection" you refer to in your code above connects you to the SQL database, not to GP in the context that you can execute Dexterity procedures.

    Thinking about it, you could probably: 1) Set a flag (or other data) in a SQL table,  2) Launch GP programatically, 3) Have a Dexterity trigger after Login to check the SQL flag, action the changes, set the flag to false and exit GP.

    Regards,

    Edwin

  • Suggested answer
    Almas Mahfooz Profile Picture
    Almas Mahfooz 11,003 User Group Leader on at
    RE: How to Execute a Dexterity Procedure Programmatically

    Parameters of Login_AlterLogin()

    Syntax

    Login_AlterLogin(data_source, user_ID, login_options, return_code

    {,new_password} {,previous_password})

  • Suggested answer
    Almas Mahfooz Profile Picture
    Almas Mahfooz 11,003 User Group Leader on at
    RE: How to Execute a Dexterity Procedure Programmatically

    I don't know about  Login_AlterLogin()

    On checking it in GP I found AlterLogin()  function, but it seems that calling this function/procedure is not enough as you can see in parameters new password is not included, further the user who is going to call this functionality must have administrative rights, I was using 'sa' user and it's showing in parameter list.

    AlterLogin() of form Enter_User_Names', 0, "Dynamics GP 2018", "almas", 0, "sa", "", 0

    check if you could access AlterLogin() of User setup form  in VSTools or not, and what parameters it is looking for.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans