public void Initialize() { // Menu to open Lookups form Dynamics.Forms.AboutBox.AddMenuHandler(OpenLookupWindow, "Lookups", ""); // Select button on the Customers lookup window Microsoft.Dexterity.Applications.SmartListDictionary.CustomerLookupForm customerLookupForm = SmartList.Forms.CustomerLookup; customerLookupForm.CustomerLookup.SelectButton.ClickBeforeOriginal += new System.ComponentModel.CancelEventHandler(CustomerSelectButton_ClickBeforeOriginal); // Select button on the Vendors lookup window Microsoft.Dexterity.Applications.SmartListDictionary.VendorLookupForm vendorLookupForm = SmartList.Forms.VendorLookup; vendorLookupForm.VendorLookup.SelectButton.ClickBeforeOriginal += new System.ComponentModel.CancelEventHandler(VendorSelectButton_ClickBeforeOriginal); // Select button on the Items lookup window Microsoft.Dexterity.Applications.SmartListDictionary.IvItemNumberLookupForm itemNumberLookupForm = SmartList.Forms.IvItemNumberLookup; itemNumberLookupForm.IvItemNumberLookup.SelectButton.ClickBeforeOriginal += new System.ComponentModel.CancelEventHandler(ItemSelectButton_ClickBeforeOriginal); // Select button on the GL Account lookup window Microsoft.Dexterity.Applications.SmartListDictionary.AccountLookupForm accountLookupForm = SmartList.Forms.AccountLookup; accountLookupForm.AccountLookup.SelectButton.ClickBeforeOriginal += new System.ComponentModel.CancelEventHandler(AccountSelectButton_ClickBeforeOriginal); // Select button on the SOP Document lookup window Microsoft.Dexterity.Applications.SmartListDictionary.SopDocumentLookupForm sopLookupForm = SmartList.Forms.SopDocumentLookup; sopLookupForm.SopDocumentLookup.SelectButton.ClickBeforeOriginal += new System.ComponentModel.CancelEventHandler(SOPDocumentSelectButton_ClickBeforeOriginal); // Select button on the POP Document lookup window Microsoft.Dexterity.Applications.SmartListDictionary.PopDocumentLookupForm popLookupForm = SmartList.Forms.PopDocumentLookup; popLookupForm.PopDocumentLookup.SelectButton.ClickBeforeOriginal += new System.ComponentModel.CancelEventHandler(POPDocumentSelectButton_ClickBeforeOriginal); // Validate script that prevents the POP Document lookup window from being displayed popLookupForm.PopDocumentLookup.PopPoLookup.ValidateBeforeOriginal += new System.ComponentModel.CancelEventHandler(PopPoLookup_ValidateBeforeOriginal); }
private void GLAccountLookup_Click(object sender, EventArgs e) { // Create a reference to the AccountLookup form Microsoft.Dexterity.Applications.SmartListDictionary.AccountLookupForm accountLookup = SmartList.Forms.AccountLookup; // Set the flag indicating that we opened the lookup GPAddIn.ReturnToLookup = true; // Open the lookup form accountLookup.Open(); // Show Posting Accounts accountLookup.AccountLookup.LocalAccountType1.Value = 1; // The sort by options are: // by Description = 1 // by Account Type = 2 // by Category = 3 // by Account = 4 // by Main Segment = 5 // by Alias = 6 // Sort by Main Segment accountLookup.AccountLookup.SortBy.Value = 5; //Run Validate on the SortBy field to fill the lookup window accountLookup.AccountLookup.SortBy.RunValidate(); }
void AccountSelectButton_ClickBeforeOriginal(object sender, System.ComponentModel.CancelEventArgs e) { // Run this code only if the Visual Studio Tools add-in opened the lookup. if (GPAddIn.ReturnToLookup == true) { // Retrieve the account number of the row selected in the scrolling window // of the Accounts lookup. The Account Number in Dynamics GP is a composite, // so an instance of that composite must be created. Microsoft.Dexterity.Applications.SmartListDictionary.AccountLookupForm accountLookupForm = SmartList.Forms.AccountLookup; Microsoft.Dexterity.Applications.DynamicsDictionary.AccountNumberCompositeData accountNumber = new Microsoft.Dexterity.Applications.DynamicsDictionary.AccountNumberCompositeData(); accountNumber = accountLookupForm.AccountLookup.AccountScroll.AccountNumber; // Now we have accountNumber, which is the Account Number composite, call a GP function // to return the string for the account number, so it can be displayed on the window. // This technique works for all account structures. string accountNumberString = Dynamics.Forms.GlAcct.Functions.ConvertAcctToStr.Invoke(accountNumber); // Set the window field to the accountNumberString value LookupsWindow.GLAccountNumber.Text = accountNumberString; // Clear the flag that indicates a value is to be retrieved from the lookup. GPAddIn.ReturnToLookup = false; } }