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

  • Author
    Posts
  • #18132

    cjparker84

    Sorry to ask what is most likely a very simple question. I’m trying to understand how I can load a record with an in-line html portlet (customer dashboard) using SuiteScript 2.0.

    In SuiteScript 1.0 I would simply define my function and have NetSuite pass the entityID in my script deployment. So for example:

    Code:
    function LoadPortlet(portlet, columns, entityid)
    From there, I could use nlapiLoadRecord to pull the customer record using the entityID and then begin pulling the field values accordingly. I cannot seem to find any clear explanation on how to pull this for an in-line html portlet using SuiteScript 2.0. I saw the modules N/record and N/currentRecord but they don’t seem to work in a portlet type script.

    I don’t mind keeping with SuiteScript 1.0, I just thought this was a good time to learn 2.0… but I’m at a loss at what I would think is a very simple step.

    Look forward to any help. Thank you!
    This is a cached copy. Click here to see the original post.

  • #18133

    michoel

    It’s passed in as part of the param object

    Code:
    /**
    *@NApiVersion 2.x
    *@NScriptType Portlet
    */
    require([‘N/record’], function(record) {
    function render(params) {
    var entityid = params.entityid;
    var recordObj = record.load({ type: record.Type.CUSTOMER, id: entityid });
    }

    return {
    render: render
    };
    });

  • #18134

    cjparker84

    Originally posted by michoel

    View Post

    It’s passed in as part of the param object

    Code:
    /**
    *@NApiVersion 2.x
    *@NScriptType Portlet
    */
    require([‘N/record’], function(record) {
    function render(params) {
    var entityid = params.entityid;
    var recordObj = record.load({ type: record.Type.CUSTOMER, id: entityid });
    }

    return {
    render: render
    };
    });

    Thanks for providing some input. I tried that earlier and kept getting an error. Not sure what I was missing/am missing. I get the below error.

    {“type”:”error.SuiteScriptError”,”name”:”SSS_MISSI NG_REQD_ARGUMENT”,”message”:”load: Missing a required argument: id”,”stack”:[“createError(N/error)”,”render(/SuiteScripts/CusDashboard_CustomerInfo.js:8)”,”createError(N/error)”],”cause”:{“name”:”SSS_MISSING_REQD_ARGUMENT”,”mess age”:”load: Missing a required argument: id”},”id”:””,”notifyOff”:false}

    I noticed that you had a require([‘N/record’]) versus I was using define, so I tried require but then I got:

    “SuiteScript 2.0 entry point scripts must implement one script type function.”

    ScriptType is defined as Portlet.

  • #18135

    cjparker84

    Ah.. I figured it out. I kept using entityid, like your script did as well. It actually uses entity instead. So the script was:

    Code:
    /**
    *@NApiVersion 2.x
    *@NScriptType Portlet
    */
    /**
    * @param {string} params.entity
    */
    define([‘N/record’], function(record) {
    function render(params) {
    var recordID = params.entity;
    var recordObj = record.load({ type: record.Type.CUSTOMER, id: recordID });
    ……

  • #18136

    michoel

    You have to love NetSuite documentation.

You must be logged in to reply to this topic.