0

I am trying to retrieve some data from custom records in Netsuite. I have set up a saved search which i am getting the results from then iterating through the search result rows to get the field values, which is ok for default fields but i can not figure out how to get the Value of a custom Field. I have a selection custom field called "custrecord_example" which i can get from the script ID but then i need to retrieve the Value. I have seen on other posts that you can use a GetSearchValue Method but i dont get get this on the SearchColumnSelectCustomField object.

Dim searchRes As SearchResult = ns_Service.search(
                New CustomRecordSearchAdvanced With {.savedSearchId = "590"})

            For pageCount As Integer = 1 To searchRes.totalPages

                For Each sRow As Object In searchRes.searchRowList
                    Dim id As Long = sRow.basic.id(0).searchValue


                    For Each custField As SearchColumnCustomField In sRow.basic.customFieldList

                        If custField.scriptId = "custrecord_example" Then

                            Dim custSelectField As SearchColumnSelectCustomField = DirectCast(custField, SearchColumnSelectCustomField)

                            'Do something here to get the Value from custSelectField

                        End If
                    Next


                Next

                searchRes = ns_Service.searchMore(pageCount + 1)

            Next
  • I am not sure about working with AdvancedSearch results but typically the custom column collection is returned as a base custom ref type and then each field in the collection may be cast to a more specific type. It is in those specific types that the value property may be found. In debug, can you check what is coming back in sRow.basic.customFieldList, carefully noting the different types? – GMan80013 Apr 25 '18 at 17:03
  • @GMan80013. The customFieldList gives me the array of custom fields, each one having a search value that gives me the internal id of the field but no value, i cant work out how to use this to get the value of the field – Connor Ferguson Apr 26 '18 at 07:36
  • the searchValue also gives me type id i.e. 417 and i can cast the custom field to a SearchColumnSelectCustomField but again no value there. – Connor Ferguson Apr 26 '18 at 07:43
  • Please try adding this in your loop this to convert your search result object to get the value - `Dim ref As ListOrRecordRef = custSelectField.searchValue` then `Dim value As String = ref.name` – GMan80013 Apr 27 '18 at 14:00
  • @GMan80013 I added the below to my loop but still no joy, everything casts fine its just the ref.name always comes through as nothing Dim custSelectField As SearchColumnSelectCustomField = custField Dim ref As ListOrRecordRef = custSelectField.searchValue Dim value As String = ref.name – Connor Ferguson Apr 30 '18 at 07:54

0 Answers0