#GPPT Iterating through a Dexterity Scrolling Window

David Meego - Click for blog homepageOver a year ago, October 2020 to be exact, I mentioned on a forum post that I have finally worked out how to cycle through a scrolling window using Dexterity code.

Being able to perform an action for each line in a scrolling window has been something that Microsoft Dynamics GP developers have been trying to do since VBA was added to version 4.0 of GP and Visual Studio Tools was added to version 9.0 of GP.

I promised I would blog about this technique … so read on for the details.

The reason it has taken me so long to write the article is that it has taken a lot of work to get to a point where the methods can work reliably when updating data on the scrolling window.

Back when I first responded to the forum post, the code was changing a field, but when attempting the same techniques on other windows, it was not reliable. Even now, the technique might need fine tuning for each situation it is used in.

To explain how the technique works, we will first discuss a “read only” situation where we will read the key fields from a scrolling window. Then we will discuss the methods to get changes to be saved and the other complexities that you might come across.

Note: This technique is using methods for referencing a form’s table buffer specific to GP Power Tools (GPPT) Build 28 or later. While it is possible in pure Dexterity to capture a reference to a form’s table buffer, the functionality is a Helper Function all in GP Power Tools.

Iteration Technique (Read Only)

Below are the steps to allow iteration through the lines of a scrolling window.

  • The scrolling window must not be in Adds Allowed mode. So use the Window_SetLineMode() function library command to change the window to LINEMODE_EDITABLE.
  • Move to the first record in the linked table’s table buffer on the form. Needs a reference to linked table buffer or GPPT MBS_Table_Buffer_Get Helper Function.
  • Start a while loop until EOF is reached.
  • Use clear window to reset the window and prepare it to be filled.
  • Fill the window using fill window from current using the current table and index to display the record in the table buffer.
  • Use the Window_SetFocus() Function Library Command to place the focus to a field on the scrolling window. This command works immediately, unlike the focus command which waits until the code has finished and control is restored to the user interface.
  • You can now read any value from the scrolling window. *
  • Move to the next record in the linked table’s table buffer on the form. Needs a reference to linked table buffer or GPPT MBS_Table_Buffer_Get Helper Function.
  • End the while loop.
  • If you changed the scrolling window line mode, remember to change it back with the Window_SetLineMode() function library command to LINEMODE_ADDS_ALLOWED.
  • Use clear window to reset the scrolling window to clear any settings.
  • Use the fill window command using current table and index to redisplay it.

* To be able to make changes to the scrolling window and get those changes saved requires additional steps.

Iteration Technique (Additional steps to allow changes)

Below are the additional steps to get the Scrolling window to allow data to be changed and have those changes saved. These steps might need tweaking for each situation as the behaviour can be affected by how the underlying Dexterity code has been written.

  • To force the Scrolling window Pre script to be executed using the Window_SetFocusLine() undocumented Function Library command with a value of 1.
  • Use the Window_SetFocus() Function Library command to set the focus to the first field you want to change.
  • Use the undocumented Map command to “tab into” a field and enter value of the passed variable into the field. This command replicates a user entering data. The data must be a variable, it cannot be an expression. This command was added to Dexterity to allow window based Service Procedures for Service Based Architecture (SBA).
  • If other fields need to be changed, use the Map command again to “tab into” the field and make the change to the values.
  • Once finished with all the changes, use the force changes window command to ensure that Dexterity knows that values have been changed on the scrolling window line.
  • Finally, use the Window_PullFocus() Function Library command to pull the focus off the scrolling window line and force the Line Change script to be executed to save the changes.

I have been working with Dexterity for almost 28 years now and only recently have got this technique working. Just reminds me of the quote attributed to Nelson Mandela: “It always seems impossible until it’s done.”

In the next article, I will publish a GP Power Tools sample using these techniques so you can see them in action and see the actual code.


19-Jan-2022: Added link for the next article: #GPPT Iterating through a Dexterity Scrolling Window Sample.

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

7 thoughts on “#GPPT Iterating through a Dexterity Scrolling Window

  1. Would this work to “search” for a row in a scrolling window? In our Sales Order fulfillment window we have lots of line items and trying to find that one line that we want to put on backorder can take a bit scrolling through them, so I was asked can I put in an item number and “search” the scrolling window for that value and have it move focus to that row in the scrolling window?


    • Hi Joel. This would not be the best technique for a find feature. Instead, you should look directly in the table for the line you want and then use the fill window from current command to jump to the line. This is how find on a lookup window works.


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 )

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.