This topic contains 6 replies, has 0 voices, and was last updated by cblackburn 8 years ago.

  • Author
    Posts
  • #1658

    MChammaTX

    I’m getting this really weird error when I’m uploading my script : “Fail to evaluate script: All SuiteScript API Modules are unavailable while executing your define callback.”

    It seems like maybe it is a problem with my define statement but I can’t spot the issue. My code is:

    Code:
    /**
    * @NApiVersion 2.0
    * @NScriptType mapreducescript
    */

    define([‘N/search’, ‘N/record’, ‘N/email’, ‘N/runtime’],
    function (search, record, email, runtime)
    {
    var PARAMS = getParams();
    function getParams()
    {
    var retData = {};
    var currScript = runtime.getCurrentScript();
    retData.inactivate = currScript.getParameter(‘custscript_its_data_wiz_inactivate’);
    retData.searchid = currScript.getParameter(‘custscript_its_data_wiz_ssid’);
    return retData;
    }
    function getInputData(context)
    {
    return search.load({ id: PARAMS.searchid });
    }
    function map(context)
    {
    log.audit(“map entry”, context.key + “|” + context.value + “|” + JSON.stringify(PARAMS));
    }
    function summarize(summary)
    {
    log.audit(“summarize”, “done”);
    }
    return {
    getInputData: getInputData,
    map: map,
    summarize: summarize
    }

    }

    );
    This is a cached copy. Click here to see the original post.

  • #1659

    MChammaTX

    Ok never mind. It seems like I can’t run the getParams function globally it has to be within a map reduce stage function.


    david.smith replied on 10/19/2016, 02:09 PM: I think I ran into that same thing before.

  • #1660

    chanarbon

    Hi @MChammaTX

    Yup. The concept is that the process is divided through stages that functions are only called during the instance that their respective entry points get triggered in the process

  • #1661

    ironside

    I have seen this error as well – on perfectly functional code. Whatever parsing engine they are passing things through does not handle advanced custom libraries very well.

  • #1662

    cblackburn

    The rule is that the “constructor” (i.e. define callback function) cannot make API calls, in order to prevent unintentional execution of the business logic when the module is being loaded and/or analyzed. This can only happen during script creation or update.

    Originally posted by ironside

    View Post

    I have seen this error as well – on perfectly functional code. Whatever parsing engine they are passing things through does not handle advanced custom libraries very well.

    ironside, would you be able to provide an example of an advanced module which was not handled well?

  • #1663

    ironside

    NFT-SS2

    ironside, would you be able to provide an example of an advanced module which was not handled well?[/QUOTE]

  • #1664

    cblackburn

    Originally posted by ironside

    View Post

    NFT-SS2

    ironside, would you be able to provide an example of an advanced module which was not handled well?

    [/QUOTE]

    “Example.ts” in the linked page is TypeScript, do you have the transpiled JavaScript version of the example available anywhere?


    ironside replied on 11/02/2016, 09:24 AM: Building NFT is the best way to get the JS. I recommend giving it a try (independent of this NS issue)!

You must be logged in to reply to this topic.