If you want to have a standard templates when adding Customer IDs and Vendor IDs, these two samples will provide that functionality with just a few triggers using the GP Power Tools – Developer Tools module.
Please note that this code is designed to work with Build 28 of GP Power Tools. There are separate projects and downloads for Customer Maintenance and Vendor Maintenance.
There is a trigger which runs when the window is opened which moves the cursor to the Customer Name and Vendor Name field, respectively. When a Name is entered, a second trigger runs and creates a prefix based on the first 8 letters entered. Then the code finds the first available number with that prefix and inserts that into the Customer ID or Vendor ID fields.
This second trigger also defaults in the primary Address Code and Class ID fields. You can adjust the code to change the defaults used or comment the code out if you don’t want that feature.
You can also adjust the code if you want to change the number of letters used for the prefix and the number portions of the resulting number.
In the screenshot below, “This is a Test” was typed into the Customer Name field and then tab was pressed. The Customer ID was defaulted to “THISISAT0001” and the Address ID and Class ID fields were populated. Pressing tab confirms the Customer ID and then you can enter the rest of the fields.
There is a third trigger in each project which is currently disabled. This trigger moves the focus to the Customer Name or Vendor Name field if it is blank and the focus is changed to the Customer ID or Vendor ID field (respectively). This is disabled to allow the custom SQL Lookup and Auto Lookup samples to work along side the auto Customer ID and Vendor ID functionality.
Check out these really cool lookup samples here:
When installing the sample code for the first time use the Configuration Export/Import window as the Project does not exist in your system yet. Just download the configuration settings file from the link at the bottom of this article. Extract the contents of the zipped archive, open Configuration Export/Import and select the configuration settings file. Click Import and click OK on the Import Settings File window when it is displayed.
This article was originally posted on http://www.winthropdc.com/blog.