How lookups work
Lookup windows in Microsoft Dynamics GP are separate forms. The core Dynamics dictionary contains lookups with basic lookup functionality. The lookup windows that the user sees in Microsoft Dynamics GP are actually alternate versions of the forms, and are defined in the SmartList dictionary. This means that your Visual Studio Tools code will reference lookups from the SmartList dictionary.
The following steps describe the basic operation of a lookup for a Visual Studio Tools integration:
Add code to track that your integration has opened the lookup.
Lookup forms can be opened by the core Microsoft Dynamics GP application, and by other integrating products. Your Visual Studio Tools integration must track that it has opened the lookup, so it will know to retrieve the value that was selected by the user.
Typically, each lookup used by a Visual Studio Tools integration is tracked using a static variable defined in the GPAddIn class. The variable must be set when the lookup is opened, and cleared when the lookup returns a value.
Add code to open the lookup form.
Typically, the user clicks a lookup button that opens the lookup form. In your Visual Studio Tools form, you will add code to the lookup button that will open the lookup form.
Register the ClickBeforeOriginal event for the Select button.
A value is returned from the lookup when the user clicks the Select button in the lookup form. You will register the ClickBeforeOriginal event on the Select button to be notified when the button is clicked.
Return the ID of the selected item.
When the user clicks the Select button in the lookup, the ID of the selected item is returned by the event handler for the ClickBeforeOriginal event. This event handler also clears the static variable that is tracking that the lookup was opened by the Visual Studio Tools integration.