Using existing lookups

You can use an existing Microsoft Dynamics GP lookup form in exactly the same manner as you use lookup forms in your own application. Each lookup form returns one or more values using the return statement. The third-party form then retrieves this value using the return to clause of the open form statement.

Keep in mind that many Microsoft Dynamics GP lookup forms require that you complete some preprocessing prior to opening the lookup form.

Opening an existing lookup form

To use an existing lookup form in your application, complete the following steps.

  1. Find out the lookup form’s table.

Find which table is used to fill the scrolling window in the lookup form you want to use, and attach that table to your form. For instance, if you open the Salesperson lookup form, attach the RM_Salesperson_MSTR table to your form.

  1. Add a return field to your table and window.

Add the Microsoft Dynamics GP field that holds the value returned from the lookup window to one of your application’s tables. This field should be a key from the table you attached in step 1. For the RM_Salesperson_MSTR table, this field is ‘Salesperson ID’. Open your window’s layout, then add this field to the layout.

  1. Add a lookup button.

Add the global field named ‘Lookup Buttons’ to the window and place it directly to the right of the lookup field.

[spacer]

Global field

Control

Lookup Buttons


This field is an array of push buttons. When you add this field to the layout, Dexterity will assign it the next available array index.

  1. Attach a lookup button script.

Attach a change script to the lookup button that’s similar to the following example. This example opens the lookup form, and returns the selected salesperson ID using the return to clause of the open form statement.

{Return the salesperson ID selected in the window.}
open form Salesperson_Lookup return to 'Salesperson ID';
'Salesperson ID' of window Salesperson_Lookup of form  Salesperson_Lookup = 'Salesperson ID';
run script 'Redisplay Button' of window Salesperson_Lookup of form Salesperson_Lookup;

A typical Microsoft Dynamics GP lookup window uses an invisible field to hold a key value passed from your window (if the user entered one), so set this field. In the previous script example, this invisible field is ‘Salesperson ID’ in the Salesperson Lookup window. Running the change script for the Redisplay button in the lookup window then fills the scrolling window using that key value with the fill window statement.

Using the from current clause in the fill window statement allows the lookup form to properly focus on a record currently displayed in your form. For instance, if a user entered a salesperson ID, then clicked the lookup button, the lookup window would place the scrolling window focus on the record with that salesperson ID.

  1. Add an accelerator key.

To enable the accelerator key for the lookup button (CTRL-L), choose Link Lookup from the Tools menu. Click the lookup button, drag the pointer to the lookup field, and release the mouse button; a highlight will flash to indicate that the link was successful.


Documentation Feedback