October 2011
M T W T F S S
« Sep   Nov »
 12
3456789
10111213141516
17181920212223
24252627282930
31  
Archives

The Importance of Selecting the Correct Extender Key Fields

David Meego - Click for blog homepageI have had a couple of recent cases which highlighted the importance of selecting the correct Key fields when creating Extender objects. Both of the cases involved adding additional user defined fields to an existing Microsoft Dynamics GP window using an Extender Window Object. In both cases, the incorrect fields were selected in the Key Fields section of the Extender Windows setup window which caused undesired behaviour.

The first example was using the Sales Order Processing window where the ‘Document Number’ field had been selected as the Key Field. This caused issues for new SOP transactions as the ‘Document Number’ is not populated until the transaction has been saved at least once. Also ‘Document Number’ is not contained in the primary key for the SOP_HDR_WORK (SOP10100) table. For this example to work properly, the Key Fields need to be ‘SOP Type’ and ‘SOP Number’.

The second example was using the Employee Maintenance window where the ‘Employee ID’, ‘First Name’ and ‘Last Name’ had been selected as Key Fields. This seemed to work until data started disappearing for specific employees. The problem here is that too many fields have been included in the Key Fields, and as the ‘First Name’ and ‘Last Name’ fields are still editable, they can be changed from the original value which “breaks” the link to the previously saved Extender data. For this example to work properly, the Key Field needs to be just the ‘Employee ID’.

Below is the screenshot of the Extender Window setup with the incorrect Key Fields defined:

Here is the Employee Maintenance window with the Employee Additional Extender window showing:

With this current setup, if you were to edit the ‘First Name’ or ‘Last Name’ fields and save the record, when you reloaded that same ‘Employee ID’ and looked at the Extender window, the Additional Data would be blank.

 

Bottom Line: For Extender to be able to successfully associate additional data with a window, it needs to have the Key Fields specified so that they match the fields contained in the primary key of the table which holds the data for that window.

 


So now we know that we should be matching the primary key fields of the main table for a window, the question is how can we identify what the main table and primary key fields are?

The following section covers some techniques that should help you:

 

Using Table Import and/or Resource Descriptions and/or SQL Commands

While you have the window you wish to link to open, select Tools >> Integrate >> Table Import.  This will display a list of associated tables (using Display Names) for the current window, from which you should be able find the main table. Press Cancel to close the window.

If you are not sure which is main table, you can use Tools >> Resource Descriptions >> Windows to lookup your window. This will provide the same list of tables (using Technical Names), but also can provide the Auto-Linked Table which is often the main table.

We now know that the Payroll Master (UPR_MSTR) is the main table for the Employee Maintenance window. Using Tools >> Resource Descriptions >> Tables and then clicking on the lookup button we can select the table.

Once selected, the Table Descriptions window lists the Keys and the Key Segments for each Key. While not always the case, the first key on a table is usually the primary key.

You can also use SQL to check the keys, using the Physical Name you can run the following command from the Query Analyzer:

exec sp_helpindex ‘UPR00100′

This command will return a list of the indexes and identify the primary key in the descriptions. Once you have the Physical Names for the fields for the primary key, you can go back to the Table Descriptions window to find the correct key and get the list of Technical Names for the fields.

So, the bottom line of this example is that the ‘Employee ID’ (EMPLOYID) field is the primary key of the Payroll Master (UPR_MSTR, UPR00100) table.

 

Using the Support Debugging Tool’s Resource Information Window

If you have the Support Debugging Tool installed, you can use Tools >> Support Debugging Tool >> Options >> Resource Information to identify the table and primary key.

Once the Resource Information window is open, make sure the Resource Type is set to Form, Window & Fields and then locate your window. You can do this by typing in the Technical or Display Name, or by using the Menu Explorer (by navigation) or Resource Explorer (by dictionary) lookups. Below shows the Menu Explorer:

If desired you can drill down and select a field that you believe is contained in the primary key, for example the ‘Employee ID’, or you can enter it manually afterwards.

Click on the Associated Tables button to display the tables linked to the form (same as the information from Table Import or Windows Descriptions) with the option to filter to only display tables containing the selected field. 

Select the desired table from the list and it will swap the Resource Information window into Table & Field mode with that table already selected.

Finally, click the Display Keys button to show the list of keys. You can then move through the keys until you find the one with Primary = Yes.

 

IMPORTANT NOTE: If you change the Key Fields for an Extender Object after it has already been used, you will need to use SQL update statements to change the underlying data to match the new Key Fields. For the EMPLOYEE Extender Window Object in this example, the following commands would fix the data.

update EXT00100 set PT_UD_Key = left(PT_UD_Key,8), Key_Strings_2 = ”, Key_Strings_3 = ” where PT_Window_ID = ‘EMPLOYEE’
update EXT00101 set PT_UD_Key = left(PT_UD_Key,8) where PT_Window_ID = ‘EMPLOYEE’
update EXT00102 set PT_UD_Key = left(PT_UD_Key,8) where PT_Window_ID = ‘EMPLOYEE’
update EXT00103 set PT_UD_Key = left(PT_UD_Key,8) where PT_Window_ID = ‘EMPLOYEE’
update EXT00104 set PT_UD_Key = left(PT_UD_Key,8) where PT_Window_ID = ‘EMPLOYEE’

This code works because the Employee ID codes used in my data are all 8 characters long. If you need further assistance with fixing Extender data, please contact your support professional.

 

I hope you find this information on how best to set up Extender object keys and the methods of identifying the primary key fields useful. 

David

More:
The Importance of Selecting the Correct Extender Key Fields

VN:F [1.9.17_1161]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.17_1161]
Rating: 0 (from 0 votes)
  • irishjamr

    Thanks for the info.  How would you determine the correct key fields to use when the keys for the GP transactional tables change?  The specific case I’m trying to handle is to add an extender window to the Edit Payables Checks window.  The key fields for PM10300 are BACHNUMB, BACHSOURC and PMNTNMBR.  However once the payment transaction is printed and posted it will wind up in PM20000 or PM30200 which both have VCHRNMBR and DOCTYPE as key fields.

    PM10300 also has VCHRNMBR and that appears to always match PMNTNMBR.  Would that be the right key to choose since it’s shared across all 3 tables?

    VA:F [1.9.17_1161]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.17_1161]
    Rating: 0 (from 0 votes)
  • irishjamr

    Thanks for the info.  How would you go about defining the key fields for the extender window when the underlying transaction will move over time between tables that have different keys? 

    The specific case I’m trying to work through is to add an extender window to the Edit Payables Checks window.  The keys for PM10300 are BACHNUMB, BCHSOURC and PMNTNMBR.  When the payment transaction is printed and posted it will then move to either PM20000 or PM30200 which each have VCHRNMBR and DOCTYPE as the keys.

    PM10300 also has VCHRNMBR which appears to always match PMNTNMBR.  Since VCHRNMBR is the common element across all 3 tables, would that be the correct key field to use for my extender window?

    VA:F [1.9.17_1161]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.17_1161]
    Rating: 0 (from 0 votes)