I think the most customized window in VBA must be the SOP Entry window.
If the customization is not saving custom data for the header/line items, then it is adding custom logic based on document type and any number of other factors.
In all of this - especially saving custom data to a parallel table - the SOP Number is important as it identifies the document. And, of course, to be unique your primary key would also include the SOP Type field - just like the SOP10100 table does in Dynamics.
Getting the SOP Number is easy - it is the string value from the window.
The SOP Type value is a bit more difficult with the introduction of Fulfillment Order SOP Type. This all would have been a lot easier if we would have just added this new type to the end of the SOP Type list. But I guess I can see it would go well with the Order type in Dynamics. So Fulfillment Order was added into the middle of the list - complicating things a bit when trying to determine if SOP Type = 3 (on the window) is an Invoice or a Fulfillment Order.
While getting the SOP Type is easy from Dexterity using the SOPTypeToInt function, that function cannot be called from Visual Studio Tools due to an anonymous field being passed to it and certainly not used from VBA since it natively cannot call Dexterity functions.
So where does that leave our enterprising VBA/VSTools developer? How do those developers get the true SOP Type value?
By referencing a hidden field added specifically for non-Dexterity developers.
Since at least 9.0, an invisible field called 'SOP Type Database' was added to the SOP Entry window. It is in the 2nd column of fields, 16 fields down off the bottom of the window. This field contains the correct "SOP Type" of the current document, the value that matches the SOP Type field stored in the SOP10100 table regardless of what the value SOP Type field in the SOP Entry would show. Just exactly what we need.
Using the field from Visual Studio Tools is easy - just reference the field as below:
From VBA it is a little more difficult because the field is off the window and invisible so not easily added to VBA without a bit of work.
To get at it with VBA, you must:
Now in VBA, instead of referencing the SOP Type field directly, reference this new field to get the actual value your code requires to properly save your parallel data.
VBA Code Snippet Example
Dim realSOPType as IntegerrealSOPType = SOPTypeDatabase
Hope this help,
// 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.)
Thank you so much for this. I was attempting to translate the SOPType field value, which doesn't work so hot between different environments that may or may not have the Fulfillment DDL option.
Dynamics GP Certified Trainer
Dynamics GP Certified Professional
Good info.. I just used this for one of the customizations I wrote - thanks for sharing with the community. Thanks, VJ
Thanks!I have been searching database tables for a solution to this - should have looked here first!!
PLEASE READ BEFORE POSTING
Please only post comments relating to the topic of this page.
If you wish to ask a technical question, please use the links in the links section (scroll down, on right hand side) to ask on the Newsgroups or Forums. If you ask on the Newsgroups or Forums, others in the community can respond and the answers are available for everyone in the future.