Mahdi Alkhatib
Mahdi Alkhatib

Reputation: 1982

Access nested object using suiteScript in Netsuite

I have added a custom field in department, namely "Symbol", and I am trying to access it from CurrentRecord (of tepy Fixed Asset) using suite script.

The current record is a fixed asset and whenever I use .getValue(), it returns departments ID and whenever I use getText() it returns Department title.

However, I need to get Department object so that I can access its custom text field I have created. That is, "Symbol" field.

How can I do that? What is the correct path?

Code

CurrentRecord.get().getValue({fieldId: 'custrecord_assetdepartment' });

Upvotes: 0

Views: 643

Answers (1)

ehcanadian
ehcanadian

Reputation: 1794

Once you have the department's internalid, you'll need to do a lookup;

 var fieldLookup = search.lookupFields({
    type: search.Type.DEPARTMENT,
    id: departmentId,
    columns: 'custrecord_assetdepartment'
});
var asset = fieldLookup['custrecord_assetdepartment'];

Upvotes: 3

Related Questions