#GPPT Form Control Adding a Customer Status Virtual Field everywhere in GP

David Meego - Click for blog homepageGP Power Tools Form Control is a “No Code/Low Code” customization tool for Microsoft Dynamics GP. It can be used to solve many requirements without any coding (or with some additional scripts).

Here is an example showing how you can quickly use Form Control to add a Virtual Field to display the Customer Status to every window in the entire Microsoft Dynamics GP application where a Customer ID is displayed, without needing Modified or Alternate windows.

In Microsoft Dynamics GP, the Customer ID field appears on many windows throughout the application, and it would be extremely useful to be able to see if a customer is over their credit limit, on hold or marked inactive, without opening additional windows.

So, the business requirement for this example is to display a Customer Status Icon on every window in Microsoft Dynamics GP where the Customer ID is displayed or entered, without needing modified or alternate windows.

This status icon will be created using Virtual Fields and displayed just to the left of the Customer ID field when the Customer ID field has a prompt.

This requirement can be created with the Form Control module combined with the Developer Tools module.

The following example shows how Virtual Fields can be added to a single window:

  • #GPPT Adding Virtual Fields to Item Maintenance

Using Form Control allows Virtual Fields to be added across multiple windows without specifically writing code for each window.

Adding the Virtual Field

The FORM CONTROL CUST VIRTUAL Form Control ID is limited by the Base Settings Resource Filters to forms beginning with RM_, SOP_, IVC_, and SVC_ to avoid Form Control processing every form in the entire product looking for windows with Customer ID field (internally called Customer Number).

The Reject Form Pre Script rule is limited to exactly the Customer Number field. This rule runs before the Form Pre Script and optionally can be used to reject the original script from running.

For our needs we are just using the Script ID field to specify the Conditional Script, which contains the commands to create the Virtual Field.

The FORM CONTROL CUST VIRT 01 Script executes when the form is opened and performs the following steps using GP Power Tools Helper Functions:

  • Gets the name of first (Main) window of the form.
  • Gets a reference to the Customer Number field on the first window.
  • Using the field reference, checks that there is a caption (prompt) for the field.
  • Using the field reference, gets the position of the Customer Number field.
  • Adds a VF_Field_StatusSwitch_01 Virtual Field to the window to the left of the field.
  • Optional handling to look for a Previous Button to the left of the Customer Number field.
  • Optional handling to move the Over Credit Icon field away, if it is found on the window.

The Execute Script in context of current form checkbox is selected so that the dictionary context used when executing the script is the same as the target form, and not the context specified on the Script ID.

Updating the Virtual Field

The After Field Value Changed Script rule is limited to exactly the Customer Number field. This rule runs after the specified field has had its value changed. It is tied to the field value, rather than when the change script for the field is executed.

For our needs we are just using the Script ID field to specify the Conditional Script which contains the commands to update the previously created Virtual Field for the current Customer ID.

The FORM CONTROL CUST VIRT 02 Script executes whenever the Customer Number field on a window is changed and performs the following steps using GP Power Tools Helper Functions:

  • Gets the field reference for the Virtual Field to check it exists on the window.
  • Gets the value of the Customer ID field.
  • Checks Credit Limit, Hold and Inactive in the tables to identify the status value and tooltip.
  • Updates the Virtual Field value and tooltip as appropriate.

Updating the Virtual Field when Hold is changed

The After Field Change Script rule is limited to exactly the Hold checkbox field on the Customer Maintenance window. This rule runs after the specified field is changed by the user.

For our needs we are just using the Script ID field to specify the Conditional Script, which contains the commands to update the previously created Virtual Field for the current Customer ID when the Hold checkbox is changed.

The FORM CONTROL CUST VIRT 03 Script executes after the user changes the Hold field and performs the following steps using GP Power Tools Helper Functions:

  • Gets the field reference for the Virtual Field to check it exists on the window.
  • Gets the value of the Customer ID field.
  • Checks Credit Limit, Hold and Inactive in the window to identify the status value and tooltip.
  • Updates the Virtual Field value and tooltip as appropriate.

Updating the Virtual Field when Inactive is changed

The After Field Change Script rule is limited to exactly the Inactive checkbox field on the Customer Maintenance window. This rule runs after the specified field is changed by the user.

For our needs we are just using the Script ID field to specify the Conditional Script, which contains the commands to update the previously created Virtual Field for the current Customer ID when the Inactive checkbox is changed.

The FORM CONTROL CUST VIRT 04 Script executes after the user changes the Inactive field and performs the following steps using GP Power Tools Helper Functions:

  • Gets the field reference for the Virtual Field to check it exists on the window.
  • Gets the value of the Customer ID field.
  • Checks Credit Limit, Hold and Inactive in the window to identify the status value and tooltip.
  • Updates the Virtual Field value and tooltip as appropriate.

Adding a Virtual Field Handler Script

The last part of this project is a Handler Script for the Virtual Field. To allow the Tooltip to work, we had to leave the Virtual Field editable. If we made the field read only, the tooltip would not be displayed.

Using the Handler Script, we can take the focus away from the Virtual Field if it is clicked on. This prevents users from changing the value even though it is editable. However, it will only work for the core Dynamics product dictionary.

The Handler Script will not work for third party products, as triggering on Virtual Fields on third party windows is not supported by Dexterity. This means that a user can click on the Status field and change it, but this will have no effect on any data and the value will be restored next time it is displayed. It was decided that having the tooltip was more useful than making the field read only.

The FORM CONTROL CUST VIRT 05 Script was added using the Runtime Execute Setup window and the 5261: VirtualFieldHandler Script Purpose.

Note: The Developer Tools module must also be registered to be able to run Form Control Conditional Scripts and use Virtual Fields.

Now the Customer ID has the Status field displayed. It will show the following status values:

  • Green: Good Status
  • Yellow: Over Credit
  • Yellow/Red: Over Credit and on Hold
  • Red: On Hold
  • Circle with line: Inactive

Here is the status on the Sales Transaction Entry window:

Downloading and Installing

Download the example settings, import using the Project Setup window (without any project showing, select the path to the xml file and click Import):

The Form Controls will be active immediately when the affected windows are next opened.

More Information

For an introduction series for Form Control with step-by-step instructions see:

For more information see:

Hope you find this example useful.

David

This article was originally posted on http://www.winthropdc.com/blog.

Leave a Reply