This topic contains 2 replies, has 0 voices, and was last updated by jshepler 6 years, 7 months ago.
-
AuthorPosts
-
March 21, 2018 at 1:38 pm #17993
david.lyleI keep seeing documentation that the 2.0 equivalent of “nlapiLoadRecord()” is “r.load()”. But how do I instantiate “r”? I’m a beginner to NetSuite/SuiteScript but have some experience with javascript.
I’m learning what I can through the chrome/firefox console before I actually save any client scripts or RESTlets in our system. My administrator doesn’t feel comfortable with me saving any scripts (not even in the sandbox) until I become more familiarized with our system. I am able to run 1.0 scripts through my browser’s javascript console, so I should be able to run 2.0 scripts too, right?
Thanks for any guidance.
This is a cached copy. Click here to see the original post. -
March 21, 2018 at 2:05 pm #17994
Ada_7B5The 2.0 equivalent of nlapiLoadRecord is record.load(options). It’s part of the N/record module. The reason you’re seeing r.load in script samples is that when you create a define or require statement, you can name the module anything.
For example, if I did:
Code:
require([“N/record”], function(cat) {
function loadAndSaveRecord() { // I named the module “cat”
var recObj = cat.load({ // Since I named the module cat,
type: cat.Type.PURCHASEORDER, // the method call is now cat.load(options)
id: 1234 // instead of record.load(options)
));
recObj.setValue({
fieldId: “location”,
value: “some location”
});
var recId = recObj.save();
}
loadAndSaveRecord();
});
And, yes, you can test your client scripts with your browser’s console. But RESTlets are server-side scripts. You can test those (to a degree) with the NetSuite ad-hoc debugger (look that up in the help). Be sure to test your server-side scripts with a require statement though. You can’t step through a 2.0 script that uses the define statement with the ad hoc debugger.
david.lyle replied on 03/22/2018, 12:07 PM: I had to install Requirify into chrome, since SuiteScript 2.0 requires this N/record module. I’m able to run basic 2.0 scripts now. Thank you, this was very helpful.
-
March 27, 2018 at 10:21 am #17995
jshepler2.0 is built around AMD, which you can read about here: https://github.com/amdjs/amdjs-api/blob/master/AMD.md
If you learn about using requirejs, you will learn much about doing modules in SS2.0, http://requirejs.org/
NS help pages have some specifics about the requirements of 2.0 scripts, https://system.na2.netsuite.com/app/…563537633.html
including the list of their modules: https://system.na2.netsuite.com/app/…220488571.html
-
AuthorPosts
You must be logged in to reply to this topic.