Open Forum

Like what you see? Discover the benefits of the GPUG Community. Learn More

VST Accessing Distribution Information

  • 1.  VST Accessing Distribution Information

    Posted 13 days ago
    I am using Visual Studio SDK to try and insert some additional validation.  Here is what I currently have for code.

    public class GPAddIn : IDexterityAddIn
        {
            // IDexterityAddIn interface
            private IvTransactionEntryForm ivTrxForm = Dynamics.Forms.IvTransactionEntry;
            private IvItemInquiryForm ivItemInq = Dynamics.Forms.IvItemInquiry;
    
            public void Initialize()
            {
                this.ivTrxForm.IvTransactionEntry.SaveRecord.ValidateBeforeOriginal += new System.ComponentModel.CancelEventHandler(TestStart);
            }
    
            void TestStart(object sender, System.ComponentModel.CancelEventArgs e)
            {
    
                IvDistributionTempTable ivDist = ivTrxForm.Tables.IvDistributionTemp;
                ivDist.GetFirst();
                string Dist = "";
                for (int i = 0; i < ivDist.AccountNumber.Length; i++)
                {
                    Dist += i.ToString() + ":  " + ivDist.AccountNumber[i].Value.ToString() + "\r\n";
                }
                
                var answer = Dynamics.Forms.SyVisualStudioHelper.Functions.DexError.Invoke(Dist);
                //e.Cancel = true;
            }
        }

    This does not produce any results.
    GP Results Image

    I have tried looking for some additional samples and maybe my Google-Fu is just not strong enough, but I cant find any code examples that give information on getting data for validation.  Ultimately the goal is to validate that the Adjustment or Variance is not using the incorrect GL accounts based on Project Selection (Job Number) to prevent posting imbalances.  Any help is appreciated.  Thanks

    ------------------------------
    Shawn Bormann
    ------------------------------


  • 2.  RE: VST Accessing Distribution Information

    GPUG ALL STAR
    Posted 12 days ago
    @Shawn Bormann

    I think the issue here is that the window is using a temporary table.

    Your VSTools code is using a new blank instance of the same temporary table ​.

    You need to get access to the actual instance of the table buffer used on the Dexterity form.

    Please note that this is something that GP Power Tools can do. It is a lot harder in VSTools.

    David

    ------------------------------
    David Musgrave MVP, GPUG All-Star

    Managing Director
    Winthrop Development Consultants

    Perth, Western Australia

    http://www.winthropdc.com
    ------------------------------



  • 3.  RE: VST Accessing Distribution Information

    Posted 11 days ago
    I found that I can get the index of the account and the offset account in this event by accessing the properties inside the scroll window, but this only works if the user has the item row selected before clicking the save button.  Is there a way to loop through all of the items in the scroll window in VS Tools?

    Dist2 = ivTrxForm.IvTransactionEntry.IvTransactionScroll.IvIvIndex;
    Dist2 = ivTrxForm.IvTransactionEntry.IvTransactionScroll.IvIvOffsetIndex;

    ------------------------------
    Shawn Bormann
    ------------------------------



  • 4.  RE: VST Accessing Distribution Information

    GPUG ALL STAR
    Posted 8 days ago
    @Shawn Bormann

    Working with Scrolling windows has always been difficult in VBA and Visual Studio. Scrolling windows are not grids and don't behave the same.

    You can only access one line of a scrolling window at a time and need to change focus to each line to be able to access the data for that line.

    With the new helper functions in Visual Studio Integration Toolkit build 15, I think you should be able to achieve what you want.

    https://winthropdc.wordpress.com/2018/11/30/vsit-visual-studio-integration-toolkit-helper-functions/

    David


    ------------------------------
    David Musgrave MVP, GPUG All-Star

    Managing Director
    Winthrop Development Consultants

    Perth, Western Australia

    http://www.winthropdc.com
    ------------------------------