NetSuite工作流操作脚本类型错误:找不到在对象标准记录中运行的函数

问题描述 投票:0回答:1

[尝试从自定义记录中获取值,并将其设置在新的批号编号为物料/物料单的项目中。启动搜索以检索值时,中途遇到此错误。搜索过滤器将项目记录中的2个值与自定义记录列表中的相同值进行比较。前几行执行没有错误。关于如何解决它的任何建议。谢谢。

               /**
               * @NApiVersion 2.x
               * @NScriptType WorkflowActionScript
               * @NModuleScope SameAccount
               */
               define(['N/record', 'N/runtime', 'N/search'],
               /**
               * @param {search} search
               */
               function(search) {
               /**
               * Function to be executed when field is changed.
               *
               * @param {Object} scriptContext
               * @param {Record} scriptContext.currentRecord - Current form record
               * @param {string} scriptContext.sublistId - Sublist name
               * @param {string} scriptContext.fieldId - Field name
               * @param {number} scriptContext.lineNum - Line number. Will be undefined if not a 
               sublist or matrix field
               * @param {number} scriptContext.columnNum - Line number. Will be undefined if not a 
               matrix field
               *
               * @since 2015.2
               */
               function onAction(scriptContext) {
                  var rec = scriptContext.newRecord;

               //Get the Item's Division value
               var itemDivision = rec.getValue('class');
               log.debug({
               title: "Get Item Division",
               details: itemDivision
               });

               //Get the Item's Business Function value
               var itemBusinessFunction = rec.getValue('custitem_swr_business_function');
               log.debug({
               title: "Get Item Business Function",
               details: itemBusinessFunction
               });

               if(itemDivision !== '' && itemDivision !== null){

               //Look up Item Approver Function using Item's Division and Item's Business Function
               var results = search.create({
                type: 'customrecord_swr_next_approver',
                filters: [
                    {
                        name: 'class',
                        operator: 'is', 
                        values: [itemDivision]
                    }, {
                        name: 'custrecord_swr_business_function',
                        operator: 'is',
                        values: [itemBusinessFunction]
                    }]
                })

               .run()
               .getRange({start: 0, end: 1});

                var itemApproverFunction = (results.length > 0) ? results[0].id : '';

                log.debug({
                title: "Get Approver Function",
                details: itemApproverFunction
                });

                //Apply acquired Item Number in transaction
                rec.setValue(itemApproverFunction);
                   }
                }
                return {
                onAction: onAction
                };

                });
workflow action netsuite
1个回答
1
投票

您在define语句中不匹配依赖项及其别名。回调函数的参数对应于依赖项列表中相同位置的元素。所以你的define

define(['N/record', 'N/runtime', 'N/search'],

function(search) {

N/record模块别名为search,然后完全不别名其他依赖项。

相反,您将需要以下内容:

define(['N/record', 'N/runtime', 'N/search'],

function(record, runtime, search) {
© www.soinside.com 2019 - 2024. All rights reserved.