Shaun.R
Shaun.R

Reputation: 41

querying the System Notes in Netsuite

I have been looking for a way to pull the records in the System Notes in NetSuite. The lines below throw an 'INVALID_RCRD_TYPE' error:

var columns = new Array();
columns[0] = new nlobjSearchColumn('internalid').setSort();
var results = nlapiSearchRecord('systemnote', null, null, columns);

I wonder how to reference the System Notes as the first argument of nlapiSearchRecord API. Obviously, it's not called systemnote.

A similar question has been posted here but the System Notes has been incorrectly referenced there.

Upvotes: 1

Views: 5281

Answers (2)

Shaun.R
Shaun.R

Reputation: 41

Thanks for your responses guys. I finally managed to query the System Notes using the code below. I thought I should share it in case someone else wants to accomplish the same job. I created a RESTlet in NetSuite using the below code that returns the list of merged customer records merged after a given date.

I created a new search with ID customsearch_mergedrecords and in Criteria tab, added a filter on 'System Notes: NewValue' where the description is 'starts with Merged with duplicates:' and in the Results tab, I added the columns I needed.

Note that you need to create the new search on Customer, not on System Notes. System Notes is hooked up in the search using join (the second argument in nlobjSearchFilter constructor).

function GetMergedRecordsAfter(input) {

var systemNotesSearch = nlapiLoadSearch('customer', 'customsearch_mergedrecords');

var filters = new Array();
filters.push(new nlobjSearchFilter('date', 'systemNotes', 'notbefore', input.fromdate));
systemNotesSearch.addFilters(filters);

var resultSet = systemNotesSearch.runSearch();
var searchResultJson = [];
resultSet.forEachResult(function (searchResult){
    var searchColumns = resultSet.getColumns();
    searchResultJson.push({
        ID:  searchResult.getValue(searchColumns[0]),
        Name: searchResult.getValue(searchColumns[1]),
        Context: searchResult.getValue(searchColumns[2]),
        Date: searchResult.getValue(searchColumns[3]),
        Field: searchResult.getValue(searchColumns[4]),
        NewValue: searchResult.getValue(searchColumns[5]),
        OldValue: searchResult.getValue(searchColumns[6]),
        Record: searchResult.getValue(searchColumns[7]),
        Setby: searchResult.getValue(searchColumns[8]),
        Type: searchResult.getValue(searchColumns[9]),
        InternalId: searchResult.getValue(searchColumns[10])
    });
    return true;
});
return searchResultJson;
}

Upvotes: 2

prasun
prasun

Reputation: 7343

systemnotes aren't available as record type which is evident from the record browser link

However, you can still get system notes fields using join searches on any record type in NetSuite

eg:

x = nlapiSearchRecord('vendor', null, null, 
  [new nlobjSearchColumn('date', 'systemNotes'),
   new nlobjSearchColumn('name', 'systemNotes'), // Set By
   new nlobjSearchColumn('context', 'systemNotes'),
   new nlobjSearchColumn('newvalue', 'systemNotes'),
   new nlobjSearchColumn('oldvalue', 'systemNotes'),
]) 

x[0].getValue('name', 'systemNotes'); //gives the set by value

Upvotes: 4

Related Questions