Announcements
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:
Background:
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.
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
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
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
Parameters of Login_AlterLogin()
Syntax
Login_AlterLogin(data_source, user_ID, login_options, return_code
{,new_password} {,previous_password})
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.
André Arnaud de Cal... 291,359 Super User 2024 Season 2
Martin Dráb 230,370 Most Valuable Professional
nmaenpaa 101,156