Adding AutoComplete Items with Dexterity

Dave Dusek - Click for blog homepageThis is a reposting of an article Dave Dusek originally wrote on my Developing for Dynamics GP blog.

This is a quick and easy way to add items to the AutoComplete list for a field.  I’m talking specifically about the AutoComplete property on a field.

In this case, the customer didn’t want to use the lookup window to select an existing item number, they wanted it to be in the AutoComplete list.  The problem is that in order for it to get into the AutoComplete list, you have to select or type it at least one time.  They wanted all of the items in the AutoComplete list right away without selecting or typing.  So this code does that for them.

The field we are targeting is the Item Number field.  This will populate any Item Number field in GP, but we need to pass a window field to the AutoComplete_AddStringValue() function, so in this case, we will use the SOP Entry window.  The code below was added on a form trigger so the user could select to update AutoComplete items.  This code could take a while depending on how may items they have, so you have to be careful when you run it and the SOP Entry window does have to be open.  Also, the AutoComplete tables are local tables, so this does have to be run on each machine for each user.

Example code to update AutoComplete data

local boolean result;
local string litem;

range clear table IV_Item_MSTR;

get first table IV_Item_MSTR;
while err() <> EOF do
  litem = 'Item Number' of table IV_Item_MSTR;

  result = AutoComplete_AddStringValue(field 'Item Number' of window SOP_Entry of form SOP Entry, litem);

  get next table IV_Item_MSTR;
end while;

warning "Update Complete.";

Dave Dusek
Dynamics GP Developer Support

// Copyright © Microsoft Corporation.  All Rights Reserved.
// This code released under the terms of the
// Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)

This article was originally posted on the Developing for Dynamics GP Blog and has been reposted on http://www.winthropdc.com/blog.

2 thoughts on “Adding AutoComplete Items with Dexterity

Please post feedback or comments

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.