I was recently asked whether GP Power Tools can be used to set a default value on a window. The answer is a very definite “Yes!”.
In fact, this sort of customisation is extremely simple with GP Power Tools and is just the tip of the iceberg for what is possible. Because we have access to Dexterity, Transact-SQL, Visual C# and Visual Basic.Net from inside GP Power Tools, the possibilities are endless and limited only by your imagination.
Also, you have the benefits of instant deployment once the triggers and scripts are enabled and saved, and everything works just fine in the Microsoft Dynamics GP Web Client too.
The following steps will demonstrate adding a Customer Class as a default to the Customer Maintenance window. You will need GP Power Tools installed and the Developer Tools module registered.
Using a GP Power Tools Trigger which executes after the Customer Maintenance window is opened, we will set the Customer Class to the default value and run the script to force any other values to be defaulted based on class. Finally, we reset the “Changed” flag on the window, so that it can be closed without trying to force a save.
- From the GP Power Tools Area page, select Inquiry >> Trigger Status.
- If any triggers are listed, select Unregister >> All Triggers. If asked, Stop Logging.
- From the GP Power Tools Area page, select Cards >> Trigger Setup. Enter the System Password or Administrator Password if asked.
- Fill in the Trigger ID and Trigger Description as appropriate (see screenshot below for my example).
- Mark the Trigger to Start Automatically on Login, Do not activate Logging Mode and Minimize Log Entries. So, all three checkboxes are selected.
- Select the Trigger Type: Focus Event, Trigger Event: Window Pre, Trigger Attach: After Original.
- Select the Window using either the Menu Lookup or the Dictionary Lookup. This will populate the Product Name, Form Name and Window Name fields. Note: You will want to use the Main window of the form (usually has the same name as the form).
- No changes are needed on the Actions tab. All checkboxes should be unselected.
- No changes to the Options tab. You can add this trigger to a Project ID, if you have more that one trigger and/or script you would like to group together.
- In the Script tab, make the script changes needed:
a) Place the cursor inside the if command at start of the line that says “OUT_Condition = true;” and press Enter to make some space. Place the cursor back to the same line and if needed press tab to indent one tab space.
b) Use the Names button in Forms, Windows & Fields mode to find the field you want to default and click OK.
c) Add a space, equals sign and space and then the value you want to default. Use double quotes before and after if the field is a string. Finish the line with a semicolon ; and press Enter.
d) Type “run script” and a space and then use the Names lookup to select the field again. Finish the line with a semicolon ; and press Enter.
e) Repeat steps b, c, & d if you want to default other fields.
f) Type “clear changes ” and a space and then use the Names lookup. Click the Back Up button once and then OK to select the window. Finish the line with a semicolon ; and press Enter.
- Optional: You can click on the Users button to restrict which users and/or companies this customisation is active for. If the Class ID used is only valid for the current company, limit this trigger to only be active for the one company. Change the view to by Company and select the correct company.
- Click Save.
The trigger is now active on all workstations (assuming GP Power Tools is correctly installed on all workstations) and will take effect on next login.
Here is the full script for this example:
out boolean OUT_Condition; OUT_Condition = false; if isopen(form RM_Customer_Maintenance) then 'Customer Class' of window 'RM_Customer_Maintenance' of form 'RM_Customer_Maintenance' = "AUSTRALIA-T8"; run script 'Customer Class' of window 'RM_Customer_Maintenance' of form 'RM_Customer_Maintenance'; clear changes window 'RM_Customer_Maintenance' of form 'RM_Customer_Maintenance'; OUT_Condition = true; end if;
Here is the example Configuration Settings file which can be imported using the Configuration Export/Import window:
Hope this is helpful.
This article was originally posted on http://www.winthropdc.com/blog.