2

Is there a proper way to get a list of all internal id in a Netsuite Record?

var record = nlapiLoadRecord('customer', 1249);
var string = JSON.stringify(record);
nlapiLogExecution('DEBUG', 'string ', string );

I can get most of the id using json string but i am looking for a proper way. It prints all the data including internal id. Is there any Api or any other way ?

Anurag Kumar
  • 165
  • 1
  • 6
  • 17

2 Answers2

9

I actually developed a Chrome extension that displays this information in a convenient pop-up.

enter image description here

I ran into the same issue of nlobjRecord not stringifying properly, and what I ended up doing was manually requesting and parsing the same AJAX page NS uses internally when you call nlapiLoadRecord()

  var id = nlapiGetRecordId();
  var type = nlapiGetRecordType();
  var url = '/app/common/scripting/nlapihandler.nl';
  var payload = '<nlapiRequest type="nlapiLoadRecord" id="' + id + '" recordType="' + type + '"/>';

  var response = nlapiRequestURL(url, payload);
  nlapiLogExecution('debug', response.getBody());

You can have a look at the full source code on GitHub

https://github.com/michoelchaikin/netsuite-field-explorer/

michoel
  • 3,725
  • 2
  • 16
  • 19
5

The getAllFields() function will return an array of all field names, standard and custom, for a given record.

var customer = nlapiLoadRecord('customer', 5069);
var fields = customer.getAllFields();

fields.forEach(function(field) {
  nlapiLogExecution('debug', field);
})
Mike Robbins
  • 3,184
  • 15
  • 20