New Module ‘N/recordContext’ for Localization

New Module ‘N/recordContext’ for Localization

In this tutorial we are going to share information about New module introduces in NetSuite. The N/recordContext module is introduced in NetSuite 2020.2. You can use this new method and enum to determine which country a script is using for execution. Use the N/recordContext Module to get all the available context types of the record, such as localization. The localization context type indicates which country a script is using for execution. You can also use the N/recordContext module to create conditional statements within a script so that the script behaves differently based on the context.

Inshort our long wait is over not we can handle the situation based on the location/localization.

recordContext.getContext(options) – Returns the record context object for a record.

recordContext.ContextType – Holds the values for the context type. In this release, the context type localization is supported.

/**

 *@NApiVersion 2.x

 */

// This example calls the getContext() API with options recordType, recordId and  record. Here we are //calling  ‘recordContext’ module

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

//returning the information related to localozation

        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

        })

    });

Feel free to reach out Netsuite Solution provider  TheSmilingCoders for proper netsuite implementationnetsuite consultation , netsuite customizationnetsuite Supportnetsuite Training NetSuite Celigo Integration , Celigo ConsultantCeligo Integration Consultant.

contact us : [email protected]

Facebook : https://www.facebook.com/Smiling-Coders-Netsuite-Training-Implementation-and-Support-1591053827660082/

Linkedin : https://www.linkedin.com/company/netsuite-academy/