The question I've seen a number of times before and been meaning to write about is: "How can I fill the Sales Order Processing scrolling window to a specific line?". With Dexterity it isn't terribly difficult but is it possible with Visual Studio Tools?
The answer turns out to be "yes" by using a feature that Dynamics GP added with GP 10 or maybe 2010 (It is the Find Item feature - Drop Down bar | Find Item. Anybody use this?).
The problem that my customer was concerned about came about due to the Suggest Items feature for GP 2013.
When this feature is activated for an item, after you enter an item in Sales Transaction Entry, the "Suggest Sales Item Entry" window will open and allow the user to select any number of items from that list. After selecting the items and hitting "OK", the window will enter the items in the back end, update the document totals, and then refill the scrolling window.
The concern was that in doing so, Dynamics GP moves focus to the Customer PO Number field and then refills the scrolling window from the top. This forces the user to scroll back to the bottom of the list and re-select the Item Number and start entering data again which slows their users down.
The Reason Why
Before clearing & refilling the SOP scrolling window, the code moves focus to the Customer PO Number and then calls the Refill_Scroll of form SOP_Entry procedure. In this case that wouldn't have been necessary but it would still refill the scrolling window which would remove focus from the window. So either way, the customer finds this annoying.
The obvious solution is that after the scrolling window is refilled (from the top), we should come behind and then have the window refilled again to the bottom on a new line so as to be able to quickly add the next item.
From Dexterity, we can use the "fill window" statement.. But for this to work right, we need it to be the SOP_LINE_WORK from the Sales Transaction Entry window. Not a huge problem but one that typically often takes a trick to do.
From Visual Studio Tools, we don't have the same equivalent - it cannot fill a scrolling window. Perhaps development will read my post and throw it in for the next version...
So thinking about the "Find Item" feature, I took a look to see how we did that. And the function is:
GetLineItemSequenceReturn() of form SOP_Entry
To be honest, it looks exactly like I'd expect. The key fields for the table and the table buffer itself (with the range already set).
With Visual Studio Tools, using the right table buffer is a piece of cake - I love the feature that it allows us to specify the table buffer instance of a form!
So to refill the scroll window as we want, all we need to do is use a focus trigger when the Suggest Sales Item Entry window closes and call the procedure above.
Trigger Handling Script
In the example above, we pull the Line Item Sequence value from SOP Entry as that will be the "next line sequence number" for the next item entered.
The SopLineWork table is passed using the form table buffer.
After I wrote and tested the solution in VSTools, I thought it would be interesting to use the Support Debugging Tool. This actually might have been difficult trying to get the SOP Entry table buffer to pass to the procedure. But as it turns out, there is a trick to that as well.
In SOP Entry, there are actually references to the SOP_HDR_WORK & SOP_LINE_WORK tables on the UI. Table References are typically colored Dark Green on the UI.
The SDT Dexterity code above uses the same call as VSTools naturally. The only real difference is the table buffer for the SOP_LINE_WORK table.
Notice that we use the SOP_SOLineState object to de-reference the table buffer and then pass it into the function.
Getting the Code
Attached to this post is a zip file that contains another zip file that holds the Visual Studio 2010 solution( with source) and the compiled assembly for GP 2013. Just copy the SOPSuggestItemsFocus.dll into the GP\Addins folder and it should start working for you.
Also in that same zip file is the Script Debugger Tool xml that does the same thing. So if you are using SDT, you can just import this solution and it will perform the same as the VSTools assembly solution.
PS: If GP crashes after you install the dll, refer to my recent blog post that explains why this happens and how to fix it.
Senior Escalation Engineer, Dynamics GP
// 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.)