Retrieve Website and Item Data

The following sample retrieves some details of the website and some item data for the specified items.

Note:

This script sample uses the define function, which is required for an entry point script (a script you attach to a script record and deploy). You must use the require function if you want to copy the script into the SuiteScript Debugger and test it. For more information, see SuiteScript 2.x Global Objects.

          /**
* @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
        };
    }
); 

        

General Notices