what's GP main window loaded event?
I'd like get company ID after GP loaded, but got nothing from Initialize() function.
*This post is locked for comments
what's GP main window loaded event?
I'd like get company ID after GP loaded, but got nothing from Initialize() function.
*This post is locked for comments
I that case, you can check for when the ToolBar window has been Opened, which occurs after logging in.
I think this will work in 99%. If I saved my user name and company name, I will be automatically logged in without clicking OK button.
Here is the code I use to read the CompanyId. The ComapnyId global variable is only populated once the user has selected the company they wish to use. You therefore have to read the value after the OK button is pressed on the Company Switch window.
static SwitchCompanyForm switchCompanyForm = Dynamics.Forms.SwitchCompany;
public void Initialize()
{
switchCompanyForm.SwitchCompany.OkButton.ClickAfterOriginal += new EventHandler(OkButton_ClickAfterOriginal);
}
static void OkButton_ClickAfterOriginal(object sender, EventArgs e)
{
int companyID = (int)Dynamics.Globals.CompanyId.Value;
}
Hope this helps
Andrew Dean
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156