//------------------------------------------------------------------ // Copyright 2018, All rights reserved, Carl Notes. // // No part of this file may be copied or used without express, written // permission of Carl Notes. //------------------------------------------------------------------
//------------------------------------------------------------------ //Script: ep_OperateInvCount_rl.js //Developer: Carl //Date: 20250808 //Description: API REST Endpoint: Operate Inventory Count // Running in nonpaged mode, per search upto 4000 results. // // ------------------------------------------------------------------
/** * @NApiVersion 2.1 * @NScriptTypeRestlet */ define(['N/error', 'N/record', 'N/runtime', 'N/search'], /** * @param{error} error * @param{record} record * @param{runtime} runtime * @param{search} search */ (error, record, runtime, search) => { /** * Defines the function that is executed when a GET request is sent to a RESTlet. * @param {Object} requestParams - Parameters from HTTP request URL; parameters passed as an Object (for all supported * content types) * @returns {string | Object} HTTP response body; returns a string when request Content-Type is 'text/plain'; returns an * Object when request Content-Type is 'application/json' or 'application/xml' * @since 2015.2 */ constget = (requestParams) => {
}
/** * Defines the function that is executed when a PUT request is sent to a RESTlet. * @param {string | Object} requestBody - The HTTP request body; request body are passed as a string when request * Content-Type is 'text/plain' or parsed into an Object when request Content-Type is 'application/json' (in which case * the body must be a valid JSON) * @returns {string | Object} HTTP response body; returns a string when request Content-Type is 'text/plain'; returns an * Object when request Content-Type is 'application/json' or 'application/xml' * @since 2015.2 */ constput = (requestBody) => {
}
/** * Defines the function that is executed when a POST request is sent to a RESTlet. * @param {string | Object} requestBody - The HTTP request body; request body is passed as a string when request * Content-Type is 'text/plain' or parsed into an Object when request Content-Type is 'application/json' (in which case * the body must be a valid JSON) * @returns {string | Object} HTTP response body; returns a string when request Content-Type is 'text/plain'; returns an * Object when request Content-Type is 'application/json' or 'application/xml' * @since 2015.2 */ constpost = (requestBody) => {
//Validate requestBody if (!requestBody.body || !requestBody.body.location||!requestBody.body.internalid||!requestBody.body.data) { error.create({ name: 'Invalid_Post_Data', message: 'Please check documenation for validate Post data', notifyOff: false }); return''; } var objInvCountBd = requestBody.body;
/** * Defines the function that is executed when a DELETE request is sent to a RESTlet. * @param {Object} requestParams - Parameters from HTTP request URL; parameters are passed as an Object (for all supported * content types) * @returns {string | Object} HTTP response body; returns a string when request Content-Type is 'text/plain'; returns an * Object when request Content-Type is 'application/json' or 'application/xml' * @since 2015.2 */ constdoDelete = (requestParams) => {
}
return { // get: post, // , put, post: post // , delete: doDelete }
(action, error, record, runtime, search) => { /** * Defines the function definition that is executed before record is loaded. * @param {Object} scriptContext * @param {Record} scriptContext.newRecord - New record * @param {string} scriptContext.type - Trigger type; use values from the context.UserEventType enum * @param {Form} scriptContext.form - Current form * @param {ServletRequest} scriptContext.request - HTTP request information sent from the browser for a client action only. * @since 2015.2 */ constbeforeLoad = (scriptContext) => {
}
/** * Defines the function definition that is executed before record is submitted. * @param {Object} scriptContext * @param {Record} scriptContext.newRecord - New record * @param {Record} scriptContext.oldRecord - Old record * @param {string} scriptContext.type - Trigger type; use values from the context.UserEventType enum * @since 2015.2 */ constbeforeSubmit = (scriptContext) => {
}
/** * Defines the function definition that is executed after record is submitted. * @param {Object} scriptContext * @param {Record} scriptContext.newRecord - New record * @param {Record} scriptContext.oldRecord - Old record * @param {string} scriptContext.type - Trigger type; use values from the context.UserEventType enum * @since 2015.2 */ constafterSubmit = (scriptContext) => {
var currentRecord = scriptContext.newRecord; var intInvCountId = currentRecord.id;
//flag for restlet API transaction if (!currentRecord.getValue('custbody_wms_invcount_id')) returntrue;
//only available for RESTLET if (runtime.executionContext != runtime.ContextType.RESTLET) returntrue;
if (!currentRecord.getValue('status')|| currentRecord.getValue('status') == 'Open' || currentRecord.getValue('statuskey') == 'A') {
oAuth 1.0 的设置中, 有个需要注意的地方: 把NetSuite Account ID 放到 header的 Realm 字段中. In Postman in your request tab and then in the authorization tab in the advanced section there is a field called Realm. Put the account id in the realm field with underscores.