Dynamics GP How to iterate through a form table in .NET

Normally, I'd do all this in SQL, but the requirement is to loop through the grid in the IVTransfer form and look at the locations (and throw an error based on business logic)

So, I need to do this in the form, before the form is saved/posted. 

Code below

Note that this code will work for any module (most questions are for SOP), just edit the table name

 

 

Sub PostButtonClickBeforeOriginal(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)
    Dim strError As String = ""
    Try
        Dim strFromLocation As String = ""
        Dim strToLocation As String = ""
 
        'this will tell us when we've reached the end of the grid
        Dim te As Microsoft.Dexterity.Bridge.TableError
 
        'get a reference to the table
        Dynamics.Forms.IvTransferEntry.Tables.IvTrxWorkLine.GetFirst()
 
        'iterate through the table
        While Not te = Microsoft.Dexterity.Bridge.TableError.EndOfTable
            strFromLocation = Dynamics.Forms.IvTransferEntry.Tables.IvTrxWorkLine.TrxLocation
            strToLocation = Dynamics.Forms.IvTransferEntry.Tables.IvTrxWorkLine.TransferToLocation
 
            If strFromLocation = "myBadLocation" Then
                e.Cancel = True
                MsgBox("Invalid location 'myBadLocation' used, POST cancelled")
                Exit Sub
            End If
 
            'increment to the next line
            'te will indicate if we're at the end
            te = Dynamics.Forms.IvTransferEntry.Tables.IvTrxWorkLine.GetNext()
        End While
 
        'if nothing bad happens, the POST will continue
 
    Catch ex As Exception
        'error handling code here
    End Try
End Sub

 

 


RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences