Anurag Kumar
Anurag Kumar

Reputation: 195

How to get a list of internal id in netsuite

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 ?

Upvotes: 2

Views: 5084

Answers (2)

michoel
michoel

Reputation: 3783

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/

Upvotes: 9

Mike Robbins
Mike Robbins

Reputation: 3297

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);
})

Upvotes: 5

Related Questions