Modules

filter

 

Objects/Functions

module (N/recordContext)

SuiteScript 2.0

Main Examples

N/recordContext Module
Member Type: Name
Search NetSuite - https://system.netsuite.com/app/help/helpcenter.nl?search=N/recordContext Module

// Code Example 1
/**
*@NApiVersion 2.x
*/
// This example calls the getContext() API with options recordType, recordId and record.
require(['N/record', 'N/recordContext'],
function(record, recordContext) {
// Create record
var employee = record.create({
type : record.Type.EMPLOYEE,
isDynamic: true
})
// Setup CA subsidiary
employee.setValue('subsidiary', 2);
employee.setValue('entityid', 'test_emp_' + Date.now())
employeeId = employee.save()

// getContext() with options recordType, recordId and contextTypes
var employeeContext = recordContext.getContext({
recordType : record.Type.EMPLOYEE,
recordId: employeeId,
contextTypes: [recordContext.ContextType.LOCALIZATION]
})
log.debug(employeeContext);
// expected log will list {"localization":["CA"]}
// Change employee subsidiary to AU
employee.setValue('subsidiary', 3);
// getContext() with options record and contextTypes
var employeeContext = recordContext.getContext({
record : employee,
contextTypes: [recordContext.ContextType.LOCALIZATION]
})
log.debug(employeeContext);
// expected log will list {"localization":["AU"]}
// Delete record
record.delete({
type : record.Type.EMPLOYEE,
id: 1
})
});

//SOURCE: https://system.netsuite.com/app/help/helpcenter.nl?fid=section_158627324548.html