This topic contains 4 replies, has 0 voices, and was last updated by michoel 6 years, 11 months ago.
-
AuthorPosts
-
November 30, 2017 at 3:38 pm #18132
cjparker84Sorry 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. -
November 30, 2017 at 4:35 pm #18133
michoelIt’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
};
}); -
November 30, 2017 at 4:55 pm #18134
cjparker84Originally 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.
-
November 30, 2017 at 5:14 pm #18135
cjparker84Ah.. 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 });
…… -
December 3, 2017 at 9:48 pm #18136
michoelYou have to love NetSuite documentation.
-
AuthorPosts
You must be logged in to reply to this topic.