This topic contains 2 replies, has 0 voices, and was last updated by kreylingj 7 years, 8 months ago.

  • Author
    Posts
  • #6481

    kreylingj

    I am trying to run an item search and link to the classification data so I can get the Class and Department descriptions without having to run a separate search for each record.

    I can get the class to be returned as a record reference but looking to return the classification data as a linked record.

    I am also having trouble figuring out how to pull “Class (No Hierarchy)”

    Attached is the code I am using trying to learn how this all fits together using VB.NET

    Public Class CenterstoneItemData

    ‘Setup log4net Logging object

    Dim logger As log4net.ILog = log4net.LogManager.GetLogger(System.Reflection.Met hodBase.GetCurrentMethod().DeclaringType)

    Public Function Process() As Boolean

    Try

    ‘ Create Transaction Search

    Dim isa As ItemSearchAdvanced = New ItemSearchAdvanced()

    ‘ Define Column Search Record

    isa.columns = New ItemSearchRow()

    ‘ Define Transaction Basic Fields to Retrieve

    isa.columns.basic = New ItemSearchRowBasic()

    ‘ Item Key Values

    isa.columns.basic.internalId = New SearchColumnSelectField() {New SearchColumnSelectField()}

    isa.columns.basic.type = New SearchColumnEnumSelectField() {New SearchColumnEnumSelectField()}

    isa.columns.basic.category = New SearchColumnStringField() {New SearchColumnStringField()}

    isa.columns.basic.class = New SearchColumnSelectField() {New SearchColumnSelectField()}

    isa.columns.basic.department = New SearchColumnSelectField() {New SearchColumnSelectField()}

    isa.columns.basic.created = New SearchColumnDateField() {New SearchColumnDateField()}

    isa.columns.basic.modified = New SearchColumnDateField() {New SearchColumnDateField()}

    isa.columns.basic.department = New SearchColumnSelectField() {New SearchColumnSelectField()}

    isa.columns.basic.displayName = New SearchColumnStringField() {New SearchColumnStringField()}

    isa.columns.basic.salesDescription = New SearchColumnStringField() {New SearchColumnStringField()}

    isa.columns.basic.stockDescription = New SearchColumnStringField() {New SearchColumnStringField()}

    isa.columns.basic.upcCode = New SearchColumnStringField() {New SearchColumnStringField()}

    isa.columns.basic.location = New SearchColumnSelectField() {New SearchColumnSelectField()}

    isa.columns.basic.locationQuantityAvailable = New SearchColumnDoubleField() {New SearchColumnDoubleField()}

    isa.columns.basic.locationQuantityBackOrdered = New SearchColumnDoubleField() {New SearchColumnDoubleField()}

    isa.columns.basic.locationQuantityCommitted = New SearchColumnDoubleField() {New SearchColumnDoubleField()}

    isa.columns.basic.locationQuantityOnHand = New SearchColumnDoubleField() {New SearchColumnDoubleField()}

    isa.columns.basic.locationQuantityOnOrder = New SearchColumnDoubleField() {New SearchColumnDoubleField()}

    isa.columns.basic.quantityAvailable = New SearchColumnDoubleField() {New SearchColumnDoubleField()}

    isa.columns.basic.quantityBackOrdered = New SearchColumnDoubleField() {New SearchColumnDoubleField()}

    isa.columns.basic.quantityCommitted = New SearchColumnDoubleField() {New SearchColumnDoubleField()}

    isa.columns.basic.quantityOnHand = New SearchColumnDoubleField() {New SearchColumnDoubleField()}

    isa.columns.basic.quantityOnOrder = New SearchColumnDoubleField() {New SearchColumnDoubleField()}

    isa.columns.basic.saleUnit = New SearchColumnSelectField() {New SearchColumnSelectField()}

    isa.columns.basic.purchaseUnit = New SearchColumnSelectField() {New SearchColumnSelectField()}

    ‘ Retrieve Linked Inventory Location Join

    isa.columns.inventoryLocationJoin = New LocationSearchRowBasic()

    isa.columns.inventoryLocationJoin.name = New SearchColumnStringField() {New SearchColumnStringField()}

    ‘ Retrieved Linked Pricing Join

    isa.columns.pricingJoin = New PricingSearchRowBasic()

    isa.columns.pricingJoin.item = New SearchColumnSelectField() {New SearchColumnSelectField()}

    ‘ Define Transaction Search Criteria

    isa.criteria = New ItemSearch()

    ‘ Define Transaction Search Basic Criteria

    isa.criteria.basic = New ItemSearchBasic()

    ‘ Limit Items to Assembly & Inventory Items Only

    isa.criteria.basic.type = New SearchEnumMultiSelectField()

    isa.criteria.basic.type.operator = SearchEnumMultiSelectFieldOperator.anyOf

    isa.criteria.basic.type.operatorSpecified = True

    isa.criteria.basic.type.searchValue = New String() {“assembly”, “inventoryItem”}

    ‘ Limit Items to Active Items Only

    isa.criteria.basic.isInactive = New SearchBooleanField()

    isa.criteria.basic.isInactive.searchValue = False

    isa.criteria.basic.isInactive.searchValueSpecified = True

    ‘ Create SA (Midland) Site Record Reference

    ‘ 8 – SA (Midland)

    Dim sarr As RecordRef = New RecordRef

    sarr.type = RecordType.location

    sarr.typeSpecified = True

    sarr.internalId = 8

    ‘ Limit Inventory Site to SA (Midland)

    isa.criteria.basic.inventoryLocation = New SearchMultiSelectField()

    isa.criteria.basic.inventoryLocation.operator = SearchMultiSelectFieldOperator.anyOf

    isa.criteria.basic.inventoryLocation.operatorSpeci fied = True

    isa.criteria.basic.inventoryLocation.searchValue = New RecordRef() {sarr}

    ‘ Limit Location to SA (Midland)

    isa.criteria.basic.location = New SearchMultiSelectField()

    isa.criteria.basic.location.operator = SearchMultiSelectFieldOperator.anyOf

    isa.criteria.basic.location.operatorSpecified = True

    isa.criteria.basic.location.searchValue = New RecordRef() {sarr}

    ‘ Create Search Result

    Dim sr As SearchResult = New SearchResult

    sr.pageSize = 1000

    sr.pageSizeSpecified = True

    ‘ Execute Search

    sr = ns.search(isa)

    ‘ Create List of Item Data

    Dim vItemDataList As List(Of ItemData) = New List(Of ItemData)

    Dim isrl As List(Of ItemSearchRow) = New List(Of ItemSearchRow)

    If (sr.status.isSuccess) Then

    ‘ Load All Search Results (1,000 records at a time)

    If sr.totalRecords > 0 Then

    Dim sid As String = sr.searchId

    Do While sr.totalRecords > (sr.pageSize * (sr.pageIndex – 1))

    For Each isr As ItemSearchRow In sr.searchRowList

    isrl.Add(isr)

    Next

    sr = ns.searchMore(sr.pageIndex + 1)

    Loop

    End If

    Dim vItemData As StringBuilder = New StringBuilder

    ‘ Process All Search Rows

    For Each isr As ItemSearchRow In isrl

    ‘ Retrieve Order Information

    Dim vTransactionType As String = If(Not isr.basic.type Is Nothing, isr.basic.type(0).searchValue.Trim, Nothing)

    Dim vTransactionInternalId As String = If(Not isr.basic.internalId Is Nothing, isr.basic.internalId(0).searchValue.internalId.Tri m, Nothing)

    Dim vLocationId As String = If(Not isr.basic.location Is Nothing, isr.basic.location(0).searchValue.internalId.Trim, Nothing)

    Next

    ‘ Write Data to Output File

    FileWriter.writeFile(vItemData.ToString, vFilePath.Trim, “ItemData”, “txt”, True)

    Return True

    Else

    Return False

    End If

    Catch ex As Exception

    logger.Error(“Error During [CenterstoneItemData] – ” & ex.Message.Trim)

    Throw ex

    End Try

    End Function

    End Class
    This is a cached copy. Click here to see the original post.

  • #6482

    chanarbon

    kreylingj

    The class for the class field is already fine. Just wondering if you refer to an existing search in NetSuite UI with only the columns defined (criteria) and you just add the criteria on your VB.net code, how does the results show on your end if you try that use case?

  • #6483

    kreylingj

    I resorted to creating a saved search and just adding the fields to the search.

You must be logged in to reply to this topic.