String fields

You can use the AutoComplete property for string fields to automatically fill the contents of the field as the user types, based on the values previously entered for the field.

Using auto-complete

To use the auto-complete capability for a string field, you must set the AutoComplete property to true for every occurrence of the field for which you want the functionality. When a user adds a value to the field and moves the focus, the value is added to the auto-complete list for the field.

When the user begins to type characters into a field with the AutoComplete property set to true, the auto-complete list for the field will be examined to find any matches. The matching items will be displayed in a drop-down list. The user can continue typing a value to refine the items listed, or use the arrow keys or mouse to select one of the items in the list. If drop-down list isn’t large enough to fully display the auto-complete items, use the resize area in the corner of the list to expand the list.

[spacer]

To remove an item from the auto-complete list, right-click the item and choose Remove From List in the menu that appears.

If the same global field appears in multiple windows, and the AutoComplete property is set to true for each instance, the fields will share the auto-complete data. Auto-complete values entered in one field will also be available in the other field instances. The behavior is the same for a local field that appears in multiple windows within a form. If each instance of the local field has the AutoComplete property set to true, the local field will share the auto-complete data.

If the auto-complete field has a linked-lookup button, an additional item will appear at the bottom of the auto-complete list. Choosing this item will open the lookup window, just as if the lookup button had been clicked. You can use the Field_SetStringProperty() function to specify the text used for this item.

[spacer]

Enabling and disabling auto-complete

You can enable or disable auto-complete for the entire application or for individual fields. Use the AutoComplete_SetMode() function to enable or disable auto-complete for the entire application.

To enable or disable auto-complete for individual fields, use the Field_SetBooleanProperty() function with the appropriate constant. To find out whether auto-complete is enabled for a field, use the Field_GetBooleanProperty() function.

Adding auto-complete items

Values are added to the auto-complete list for a field any time the focus moves to the field, the content of the field changes, and the focus leaves the field. A user changing a field’s value, or a lookup window returning a value are common ways that values are added to the auto-complete list.

From sanScript, you can use the AutoComplete_AddStringValue() function to add values to the auto-complete list. This can be useful if you want to pre-load a set of auto-complete values for a specific field.

Saving auto-complete items

When you run your application with the Runtime engine, the auto-complete items are written to files that are stored in the “Application Data” folder for the user currently logged into the workstation. The auto-complete values stored in this table will be used the next time the application is run.

Inside the “Application Data” folder is the “Microsoft Business Solutions” folder, which contains another folder that is based on your application’s name. By default, auto-complete files will be stored here. If you want your application to have multiple sets of auto-complete items, such as one set for each different company, you can use the AutoComplete_SetOptions() function to specify the name an additional folder that will be created to store the auto-complete files.

If you’re running your application in test mode, auto-complete items will work for the current session, but are not stored in this file.


Removing auto-complete items

You can use the AutoComplete_RemoveFieldData() function to remove all the auto-complete items for a specific field. To remove only specific auto-complete items for a field, use the AutoComplete_RemoveStringValue() function. Users can remove a specific auto-complete item by right-clicking it and choosing to remove it. You can remove all auto-complete items by calling the AutoComplete_RemoveAllData() function.

Auto-complete items can also be removed automatically. The AutoComplete_SetOptions() function allows you to specify the maximum number of auto-complete items a field can have. If this limit is exceeded, the oldest auto-complete items are deleted. You can also specify how long unused auto-complete items remain in the auto-complete data. Each time an auto-complete item is selected, it is updated with the workstation’s current system date. If the age of an auto-complete item exceeds the specified limit, the item will be removed.


Documentation Feedback