Modules in the N/commerce namespace have been designed for use with SSP applications written in SuiteScript 2.x. Their primary objective is to provide web developers a homogeneous development experience when working with Commerce and SuiteScript APIs. Note that N/commerce itself is not a module.
Developers can use modules in the N/commerce namespace to access different assets in the web store context, such as items and shopping cart. The modules within the N/commerce namespace are supported by the latest version of SuiteCommerce and by SuiteCommerce Advanced 2019.2 onwards.
Before you can load N/commerce modules, you must have an active shopping session.
The modules available within the N/commerce namespace are:
N/commerce/recordView Module Members
| Member Type | Name | Return Type / Value Type | Supported Script Types | Description |
|---|---|---|---|---|
| Method | recordView.viewItems(options) | Object | arrayReturns one or more Items with requested items fields as an object with field:value pairs.See | Client and server scripts | Retrieves one or more Items with requested items fields from an Item Record. |
| recordView.viewWebsite(options) | ObjectReturns website and website fields as an object with field:value pairs.See | Client and server scripts | Retrieves the website details with requested website fields. |
Sample Code
/**
* @NApiVersion 2.x
*/
define(['N/commerce/recordView'],
function (recordView) {
function service(context) {
var result = {};
try {
result.website= recordView.viewWebsite({
id: 2,
fields: ["internalid","shiptocountries"]
});
}
catch (e) {
result.websiteError = e.name + ": " + e.message;
}
var options = {
"ids": [382,388],
"fields": ["displayname"]
};
try {
result.items= recordView.viewItems(options);
}
catch (e) {
result.itemsError = e.name + " : " + e.message;
}
return context.response.write(
JSON.stringify(result)
);
}
return {
service: service
};
}
);