#GPPT Form Control Working with Phone and Fax Numbers including Conditional Formats

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 a small conditional script).

Here is a real-life example showing how you can quickly use Form Control to control phone and fax numbers in Microsoft Dynamics GP throughout the whole product.

In Microsoft Dynamics GP you are allowed to use almost any character when entering phone and fax numbers.

It is unlikely that unwanted symbols will be entered by users, but they are not prevented. You might also decide that you do not want letters used and that only numbers should be entered.

Using Form Control you can strip unwanted characters (and leading and trailing spaces) from the phone and fax number fields to just leave the approved characters.

It is also possible to add formatting using Form Control when the formats have been removed using Modifier.

Strip Unwanted Characters from Phone and Fax Numbers

The FORM CONTROL PHONE Form Control ID is currently not limited by the Base Settings Resource Filters, so it will check all forms.

The Strip Invalid Field Characters rule is limited to fields containing Phone or Fax.

However, there are many field names used for storing Phone and Fax Numbers, so the Resource Information window was used to see what fields contain the terms “phone” and “fax” and then some exclusions could be added to remove the fields that contain those terms but are not a phone or fax number.

Entering the Field Technical Name and pressing Tab searches all dictionaries for fields containing the term entered.

Clicking on fields in the list will display the Data Type Information so we can identify which fields are not storing a phone or fax number and add an appropriate exclusion to the Form Control ID.

The Expression specifies that numbers, spaces, plus symbols and dashes are valid characters.

Note: Additional characters can be added to the Expression field, but the dash must be the last character otherwise it will be interpreted as specifying a range of characters.

Optional: Formatting Phone and Fax Numbers

The optional Format String Field Value rule can be enabled to format phone and fax numbers when the default format specified has been removed with Modifier. The desired format can be specified in the Expression field.

In this example, a Script ID has been added with a script which will programmatically insert formats into the Expression field based on the data entered. The example script is designed for use in Australia where different classifications of phone numbers are formatted differently. If none of the standard types of numbers are used, no format is applied.

  • 1800 numbers formatted as 9999 999 999
  • 1300 numbers formatted as 9999 999 999
  • 13 numbers formatted as 99 99 99
  • 04 mobile numbers formatted as 9999 999 999
  • Landline numbers formatted as 99 9999 9999

Code Excerpt from FORM CONTROL PHONE Form Control Conditional Script

if substring(MBS_FormControl_Value, 1, 4) = "1800" then
	call with name "MBS_Control_Update_Expression" in dictionary 5261, "9999 999 999";
elseif substring(MBS_FormControl_Value, 1, 4) = "1300" then
	call with name "MBS_Control_Update_Expression" in dictionary 5261, "9999 999 999";
elseif substring(MBS_FormControl_Value, 1, 2) = "13" then
	call with name "MBS_Control_Update_Expression" in dictionary 5261, "99 99 99";
elseif substring(MBS_FormControl_Value, 1, 2) = "04" then
	call with name "MBS_Control_Update_Expression" in dictionary 5261, "9999 999 999";
elseif substring(MBS_FormControl_Value, 1, 1) = "0" then
	call with name "MBS_Control_Update_Expression" in dictionary 5261, "99 9999 9999";
else	
	call with name "MBS_Control_Update_Expression" in dictionary 5261, "";
end if;

The MBS_Control_Update_Expression Helper Function is used to change the expression before it is applied.

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

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 https://www.winthropdc.com/blog.

Leave a Reply