eConnect - IVItemMasterType, taUpdateCreateItemRcd, taCreateItemVendors_ItemsTaCreateItemVendors

Sample code to create an item, itemSite, and itemVendor. We're using the IVItemMasterType, taUpdateCreateItemRcd, taCreateItemVendors_ItemsTaCreateItemVendors and taItemSite_ItemsTaItemSite schema

 

This code uses classes that are passed in to the routine that we're not showing; the point of posting this here is to have some boilerplate code that can quickly be copied into a new project and edited. The source of the data changes on each project, but the code is largely the same

All our eConnect code uses the common functions class

 

    Sub UpdateCreateItem(ByVal datasetClaim As DataSetClaim)
        '        If you provide a Partnumber then I can create an item number based on the ManufactID plus the Partnumber
 
        Dim strItemNumber As String = ""
        Dim bSuccess As Boolean
        Dim oDT As DataTable = Nothing
 
        Try
 
            For Each li As lineItem In datasetClaim.lineItem
                Dim strPartNumber As String = li.PartNumber
                Dim uManufacturerID As Guid = New Guid(li.ManufactID)
                Dim intLineItemType As Int16 = li.LineItemType
                Dim uFormID As Guid = New Guid(li.FormID)
                Dim strFieldName As String = li.FieldName
                Dim strLineItemGroup As String = li.LineItemgroup
                Dim uBreakOutID As Guid = li.BreakOutID
 
                oDT = SPs.FP_PM00200EXT_SEL_byManID(New Guid(li.ManufactID)).getTable
                If oDT.Rows.Count = 0 Then
                    Throw New Exception("Unable to locate vender while creating item")
                End If
 
                Dim strVendorID As String = oDT.Rows(0)("VendorID")
 
                'update/create the item
                'get the server and database from the config
                Dim strServer As String = System.Configuration.ConfigurationManager.AppSettings("SQLServer")
                Dim strDatabase As String = System.Configuration.ConfigurationManager.AppSettings("Database")
 
                oDT = SPs.FP_IV00101EXT_INSSEL(strPartNumber, uManufacturerID, intLineItemType, uFormID, strFieldName, strLineItemGroup, uBreakOutID).getTable
                If oDT.Rows.Count = 0 Then
                    Throw New Exception("Unable to get an item number")
                End If
                strItemNumber = oDT.Rows(0)("ITEMNMBR")
 
                'update the item
 
                'create the objects that we'll need
                Dim oeConnectType As New Microsoft.Dynamics.GP.eConnect.Serialization.eConnectType
                Dim oIVitemMasterType As New Microsoft.Dynamics.GP.eConnect.Serialization.IVItemMasterType
                Dim otaUpdateCreateItemRcd As New Microsoft.Dynamics.GP.eConnect.Serialization.taUpdateCreateItemRcd
                Dim otaCreateItemVendors As New Microsoft.Dynamics.GP.eConnect.Serialization.taCreateItemVendors_ItemsTaCreateItemVendors
                Dim otaItemSite As New Microsoft.Dynamics.GP.eConnect.Serialization.taItemSite_ItemsTaItemSite
 
                'this is our common eConnect class, it can be found on the KB menu under eConnect
                Dim oeConnectFunctions As New eConnectFunctions(strServer, strDatabase)
 
                oDT = SPs.FP_IV40700_SEL(datasetClaim.CompanyAddress.City).getTable
                If oDT.Rows.Count = 0 Then
                    Throw New Exception("Unable to get an location code")
                End If
                Dim strLocationCode As String = oDT.Rows(0)("LOCNCODE")
 
 
                With otaUpdateCreateItemRcd
                    .ITEMNMBR = strItemNumber
                    .ITEMDESC = Left(li.ItemDescription, 101)
                    .ITMCLSCD = Left(strVendorID, 10)
                    .UOMSCHDL = "EA"
                    .CURRCOST = li.Cost
                    .CURRCOSTSpecified = True
                    .LOCNCODE = strLocationCode
                    .UseItemClass = 1
                    .UpdateIfExists = 1
                End With
 
                With otaItemSite
                    .ITEMNMBR = strItemNumber
                    .LOCNCODE = strLocationCode
                End With
 
 
                With otaCreateItemVendors
                    .ITEMNMBR = strItemNumber
                    .VENDORID = strVendorID
                    .VNDITNUM = strItemNumber
                    .Last_Originating_Cost = 0
                End With
 
                oIVitemMasterType.taUpdateCreateItemRcd = otaUpdateCreateItemRcd
 
                ReDim Preserve oIVitemMasterType.taCreateItemVendors_Items(0)
                oIVitemMasterType.taCreateItemVendors_Items(0) = otaCreateItemVendors
 
                ReDim Preserve oIVitemMasterType.taItemSite_Items(0)
                oIVitemMasterType.taItemSite_Items(0) = otaItemSite
 
                ReDim Preserve oeConnectType.IVItemMasterType(0)
                oeConnectType.IVItemMasterType(0) = oIVitemMasterType
 
                bSuccess = oeConnectFunctions.CreateEntity(oeConnectType)
 
            Next
        Catch ex As Exception
            Throw ex
        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