Welcome to the second article in the series of articles that explains in detail the steps to add a user defined custom field to a window using Modifier, Report Writer and GP Power Tools to add the business logic.
The series should be read in order starting with the introduction article:
In this article we will use Modifier to add the custom field to the Item Maintenance window.
For the business example we are working through, we need to add an internet URL field to the Item Maintenance window which can be opened in an internet browser.
The process to do this can be broken down into 6 Steps:
- Modifying the Window; Use Modifier to add the URL field to the Item Maintenance window with a hyperlinked prompt.
- Saving the Data; The data will be stored in the DUOS (Dynamic User Object Store) SY90000 table and business logic will be added to handle saving the URL field.
- Using the Data; Make the hyperlink open the URL in a browser window.
- Creating the Report Writer Function; Use Power Tools to create a Report Writer Function to allow the data to be pulled into reports.
- Modifying the Report; Use Report Writer to add a calculated field to call the Report Writer Function.
- Publishing the Project; Change settings to make the project available to all users.
Follow the steps below to complete Step 1: Modifying the Window to add the URL field to the Item Maintenance window. The steps below are valid when using Modifier with any of the scripting tools. (Click on images to see full sized versions).
- Open the Item Maintenance window (Cards >> Inventory >> Item).
- From the Tools Menu, select Customize >> Modify Current Window. This will take you to the Modifier with the IV_Item_Maintenance window opened in the Layout editor.
- In the Toolbox (left hand window), change the drop down list from Global Fields to Local Fields. If the Toolbox window is not showing, press Ctrl-B or select Layout >> Toolbox from the menus. Click New to open the Local Field Definition window.
- Enter the Field Name as URL, leave Array Size as 0, set the Control Type to String and enter the Keyable Length to 100. We will leave the format blank as the field is to be unformatted. Note: The Keyable Length can be anything up to 132 if using the DUOS table to store data, as that is the length of the data column in the SY90000 table.
- Click OK to close the window and scroll through the list of Local Fields in the Toolbox to find the newly added field.
- The next step is to make room on the window for the new field. As many of the original windows in Dynamics GP are not exactly sized to the grid, it is best to manually resize the window by entering the number of pixels rather than dragging the edge with the mouse. In the window Layout window, click anywhere in the window that is window background or unused space to select the Window. On the Properties window click on the visual tab to show the visual properties. If the Properties window is not showing, press Ctrl-M or select Layout >> Properties from the menus.
- To make the window one grid size bigger, increase the Size-Height property by 19 pixels. Double click on Size-Height, change 417 to 436 and press Enter.
- To insert our new field in-between Shipping Weight and Tax Commodity Code, use the mouse to select all the fields (drag and drop) from Tax Commodity Code to the bottom of the window. Note: You must fully surround a field for it to be selected. To make sure you include the horizontal line, click to the bottom right and slowly drag up and left.
- Click on one of the selected fields and drag and drop all the fields one grid position down.
- Drag and drop the URL Local Field from the Toolbox window into the space created on the window above Tax Commodity Code. The field will be aligned to the grid when dragged out and so might not line up with existing fields.
- Use the Arrange tab of the Toolbox window to adjust the position of the field. Click on Arrange tab. Click on the URL field, shift-click on the Tax Commodity Code field. Click on the Align to Bottom button and then the Align to Left. Click on the window background to de-select fields. Click on the URL field again and drag it up one grid position. You can use arrow keys to move one pixel at a time, but the arrange tools can be quicker.
- Use the mouse to change the size of the field so that it is close to the desired width. If you need to fine tune the field width: use Shift-Right Arrow to make it wider by one pixel; or Ctrl-Left arrow to make it narrower by one pixel. Change the width so that the right hand edge lines up with existing fields. Note: You can also use the arrange tools Size to Narrowest and Size to Widest to get field widths matched up.
- Now let’s add the field prompt. On the Layout tab of the Toolbox window, click on the Text “A” button. Click in the space where the prompt should go and type in the desired text, in our case Web URL Link, and press Tab. Don’t worry if it is not lined up with the existing prompts. If you need to edit a prompt, use the Text button and then click on the text you want to edit.
- Use the arrange tools on the Align Tab of the Toolbox window to position and size the prompt. Click on the prompt and shift-click on the URL field and Align to Bottom. Shift-click on the URL field to de-select it and shift-click on the Tax Commodity Code prompt. Then use the arrange tools Align to Left and Size to Widest.
- Click on the Web URL Link Prompt, then on the Visual tab of Properties window change the following settings: Appearance: 3D Highlight, Border: True. This will show the line underneath the prompt. If the line does not reach to the left hand side of the field, you will need to size the prompt wider.
- The next step is to link the prompt to the field. This is important as it allows the prompt to be controlled by the field. This makes the prompt change when the field is required or when the field is disabled. From menus select Tools >> Link Prompt or press Ctrl-E, then drag from the field to the prompt to link them. The prompt will flash when linked. While in Link Prompt mode you can click on a field to see the linked prompt. You can also drag from a field to a blank area to remove the linked prompt. From menus select Tools >> Link Prompt or press Ctrl-E to turn off Link Prompt mode.
- Now we will set the tab sequence to add the field above the Tax Commodity Code in the sequence. From the menus select Layout >> Set Tab Sequence. Press tab (and shift-tab) to move through the sequence. Whenever the sequence goes to a field that is incorrect, double click on the correct field and then press tab to keep moving through the sequence. You must press tab to keep moving through, if you just double click on fields in the order you want without pressing tab, you will reverse the order. Tab down to Tax Commodity Code and then double click on URL Field. From the menus select Layout >> Set Tab Sequence to exit Tab Sequence mode.
- The next few steps are to add a hyperlink to the field and might not be needed for other projects (jump to step 23). On the Layout tab of the Toolbox window, make sure the drop down list is on Local Fields and click New. Enter the Field Name as Zoom Button, Control Type as Push Button and click on the Ellipses button next to Static Values and enter “Zoom” as the Up Caption. Click OK and Click OK to close the Local Field Definition.
- On the Layout tab of the Toolbox window locate the Zoom Button field and drag it onto the window layout to the right and below the prompt. This is a temporary location and is just to make it easier to adjust the properties, position and size of the field.
- Click on the Web URL Link prompt and change the following Visual Property: Zoom: True. This adds the hyperlink appearance to the prompt.
- Now click on the Web URL Link prompt and shift-click on the Zoom button to select both. Then use the arrange tools: Align to Top, Align to Left, Size to Widest, Size to Shortest. Click on the background to deselect the fields.
- Click on the Zoom Button and change the following Object Property: TabStop: False. Then change the following Visual Properties: Zoom: True, Visible: False. This will make the button invisible and make the mouse pointer change to a “hand” while hovering over the button, this completes the hyperlink effect. If invisible fields are not being shown, the button will no longer be visible. If you want to see the field, from the menu select Layout >> Show Invisible Fields.
- If you want to see a preview of the window, you can select Layout >> Preview or press Ctrl-5 to see the window. Note that no code will run in preview mode. Click on the close box of Layout window and click Save and click OK. Then select File >> Microsoft Dynamics GP to return to exit Modifier.
That completes the changes needed to the window. The changes will not work as there is no code or business logic added yet. Also, if you want to see the window the security records have not yet been changed to show the Modified window instead of the Original window.
Using the GP Power Tools Dynamic Product Selection feature, we can make the Modified window available to your user while we are still developing the customization.
- Using the GP Power Tools Area Page, select Setup >> Dynamic Product Selection. Use the lookup on the right hand side to select the Modified/Alternate ID that your User ID is using. Expand nodes on the left hand pane to the Inventory series.
- On the left hand pane, locate Item Maintenance and select it. Then click on the checkbox to enable Dynamic Product Selection on this window. Expanding the node will show which version of the window is selected as per the security settings. On the right hand side select the versions you want to be able to select from (best to keep the options to 3 or less).
- Click on the Users Button on the Toolbar and select your User ID and make sure the Exclude Selected Users checkbox is unchecked.
- If desired, you can select the options on the right hand pane and change the Description and Short Descriptions. You can also re-order the options and/or limit specific options on a per user/company basis. We don’t need to change any additional settings, so just click Save.
Now when your User ID (and only your User ID) is used to open Item Maintenance, you will get a dialog allowing you to choose which version of the window to open.
We will leave this setting in place while we are developing and testing the customization. Here is what the now modified Item Maintenance window looks like.
In the next article we will add business logic to make the new field functional.
Hope you find this series useful.
This article was originally posted on http://www.winthropdc.com/blog.