This topic contains 4 replies, has 0 voices, and was last updated by TheUsualSuspect 6 years, 11 months ago.

  • Author
    Posts
  • #18303

    TheUsualSuspect

    NetSuite apparently uses 1.0 functions internally for some 2.0 functions?

    Here is what nlapiGetCurrentLineItemIndex does as a bonus.

    Here is a snippet to load 2.0 in the console for anyone wanting to test it / look at the source code

    Code:
    require([‘N’])
    var currentRecord = require(‘N/currentRecord’);
    cr = currentRecord.get();
    var record = require(‘N/record’);
    var search = require(‘N/search’);
    var runtime = require(‘N/runtime’);
    var dialog = require(‘N/ui/dialog’);
    var format = require(‘N/format’);
    I found out how to do this in this video
    This is a cached copy. Click here to see the original post.

  • #18304

    tgrimm

    Found this same thing a while back stepping through the debugger. I am pretty sure that all 2.0 code is in someway calling the 1.0 version of the API. Its quite odd…. I did not however know how to do 2.0 code in the console before reading this though, so thank you much!

  • #18305

    TheUsualSuspect

    Originally posted by tgrimm

    View Post

    Found this same thing a while back stepping through the debugger. I am pretty sure that all 2.0 code is in someway calling the 1.0 version of the API. Its quite odd…. I did not however know how to do 2.0 code in the console before reading this though, so thank you much!

    No problem. Greatly helped me pick up 2.0 to be able to play around with it in the console

  • #18306

    zackb22

    Originally posted by TheUsualSuspect

    View Post

    No problem. Greatly helped me pick up 2.0 to be able to play around with it in the console

    You can also get something like TamperMonkey and then run a script to load the requires on any netsuite page. Then you can just start typing your code and not deal with the requires.

  • #18307

    TheUsualSuspect

    Using some code I parsed all of 2.0 UI modules and found the occurrences of 1.0 in each 2.0 module with a total of 106 calls.

    N/auth not available in the UI

    N/cache not available in the UI

    N/config not available in the UI

    N/crypto not available in the UI

    N/currency: 1

    N/currentRecord: 33

    N/email: 0

    N/encode not available in the UI

    N/error: 5

    N/file: 2

    N/format: 0

    N/http: 0

    N/https: 0

    N/log: 0

    N/plugin not available in the UI

    N/portlet: 0

    N/record: 4

    N/redirect not available in the UI

    N/render not available in the UI

    N/runtime: 0

    N/search: 0

    N/sftp not available in the UI

    N/sso not available in the UI

    N/task not available in the UI

    N/transaction: 1

    N/ui/dialog: 0

    N/ui/message: 0

    N/ui/serverWidget not available in the UI

    N/url: 4

    N/util: 0

    N/workflow not available in the UI

    N/xml: 3

    N/auth not available in the UI

    N/cache not available in the UI

    N/config not available in the UI

    N/crypto not available in the UI

    N/currency: 1

    N/currentRecord: 33

    N/email: 0

    N/encode not available in the UI

    N/error: 5

    N/file: 2

    N/format: 0

    N/http: 0

    N/https: 0

    N/log: 0

    N/plugin not available in the UI

    N/portlet: 0

    N/record: 4

    N/redirect not available in the UI

    N/render not available in the UI

    N/runtime: 0

    N/search: 0

    N/sftp not available in the UI

    N/sso not available in the UI

    N/task not available in the UI

    N/transaction: 1

    N/ui/dialog: 0

    N/ui/message: 0

    N/ui/serverWidget not available in the UI

    N/url: 4

    N/util: 0

    N/workflow not available in the UI

    N/xml: 3

    Total usage: 106

    Code:
    require([‘N’]);

    var modules = [‘N/auth’, ‘N/cache’, ‘N/config’, ‘N/crypto’, ‘N/currency’, ‘N/currentRecord’, ‘N/email’, ‘N/encode’, ‘N/error’, ‘N/file’, ‘N/format’, ‘N/http’, ‘N/https’, ‘N/log’, ‘N/plugin’, ‘N/portlet’, ‘N/record’, ‘N/redirect’, ‘N/render’, ‘N/runtime’, ‘N/search’, ‘N/sftp’, ‘N/sso’, ‘N/task’, ‘N/transaction’, ‘N/ui/dialog’, ‘N/ui/message’, ‘N/ui/serverWidget’, ‘N/url’, ‘N/util’, ‘N/workflow’, ‘N/xml’, ‘N/auth’, ‘N/cache’, ‘N/config’, ‘N/crypto’, ‘N/currency’, ‘N/currentRecord’, ‘N/email’, ‘N/encode’, ‘N/error’, ‘N/file’, ‘N/format’, ‘N/http’, ‘N/https’, ‘N/log’, ‘N/plugin’, ‘N/portlet’, ‘N/record’, ‘N/redirect’, ‘N/render’, ‘N/runtime’, ‘N/search’, ‘N/sftp’, ‘N/sso’, ‘N/task’, ‘N/transaction’, ‘N/ui/dialog’, ‘N/ui/message’, ‘N/ui/serverWidget’, ‘N/url’, ‘N/util’, ‘N/workflow’, ‘N/xml’];

    var totalOccurances = 0;
    for (var mIndex = 0; mIndex < modules.length; mIndex++) {
    var moduleString = modules[mIndex];
    try {
    var nlapiModule = require(moduleString);
    if (moduleString === ‘N/currentRecord’) nlapiModule = nlapiModule.get();
    var SSLibString = parseFunctions(nlapiModule);
    var nlapiOccurances = (SSLibString.match(/nlapi/gim) || []).length;
    totalOccurances += nlapiOccurances;
    console.log(moduleString + “: ” + nlapiOccurances);
    } catch (error) {
    console.log(moduleString + ‘ not available in the UI’);
    }
    }
    console.log(“Total usage: ” + totalOccurances);

    function parseFunctions(node) {
    if (typeof node === ‘function’) {
    return node.toString().replace(/s/gim, ”);
    } else if (typeof node === ‘object’) {
    var results = [];
    for (var element in node) {
    results.push(parseFunctions(node[element]));
    }
    return results.join(‘n’);
    } else {
    return ”;
    }
    }

You must be logged in to reply to this topic.