Have you ever found yourself performing time-consuming actions repeatedly in Microsoft Dynamics GP? Perhaps you need to enter the same transaction type for several customers, inventory items, or assets. A client of ours found themselves in this situation. They had a list of Assets and the amounts by which each asset’s Cost Basis was to increase or decrease. Other business processes would create this list, and once the list was ready, it was stored in their database. A user would manually go through the list, and for each asset, they would enter the asset on the Fixed Assets Book Maintenance window. They would then update the Cost Basis with the corresponding amount.
By creating a GP Add-in using Visual Studio Tools for Microsoft Dynamics GP, our solution simply automated the actions that a user would perform (Figure 1).
We created a window to display the list of Assets to the user, and when they clicked a ‘Process’ button, each asset would get entered into the Fixed Assets Book Maintenance window, its Cost Basis updated, and then the record saved (Figure 2).
A slight complication occurred when the Asset record was saved and the user was presented with two dialog boxes where they had to make a selection. The first presented the user with a “Yes/No” question. The second was a multiple choice. In both cases, we were able to have the code make the selection on behalf of the user.
First, we have to register an event-handler to handle modal dialog boxes that the Book Maintenance window may generate:
The event-handling code above will run whenever the Book Maintenance window displays a dialog box. The user may be presented with any number of messages/questions, but in our case, we only care about two: one asking if depreciation values should be recalculated, and the other asking which method should be used to reset the asset values.
Since we know the exact wording of these messages, we look for those exact messages and respond appropriately. In the first case, we always want to choose the first option of “Yes,” indicating that we want to continue with the recalculation. In the second case, we always want to select the third option of “Recalculate.”
By creating a relatively simple add-in, we were able to provide a solution that saved our client many hours of manual entry, freeing them up to work on other things.