rcrd_dsnt_exist”,“消息”:;没有这种类型的记录

发布于 2025-02-08 02:55:52 字数 1342 浏览 4 评论 0原文

好的,大家,非常透过这杯上的玻璃杯。 非常感谢Barmar,Kryton和Bknights,他们的智慧帮助我这么远。

脚本已经改变,现在在下面。我可以将其上传并生成脚本记录,并且它确实尝试运行,但是现在我遇到了此错误:

“ type”:“ error.suitescripterror”,“ name”:“ rcrd_dsnt_exist”,“ message”:“: “没有这种类型的记录。”,“ stack”:[“ createError(n/error)”,“ initiateworkflow(/suitescripts/grn20.js:9)”],“原因”:{“ type”:'type“:”内部错误”,“代码”:“ RCRD_DSNT_EXIST”,“详细信息”:“没有此类型的记录。 InitiateWorkflow(/suitescripts/grn20.js:9)“],“ notifyOff”:false},“ id”:“”,“ notifyOff”:false,“ userfacing”:false}

但是记录确实存在,ID号和工作流ID如工作流中指定。

还有什么可能导致这个问题?

预先感谢您提出任何建议!

编辑 - 我被告知下面的记录ID应该参考项目的内部ID,这是没有意义的,我要启动的工作流程旨在更改多个项目的字段,为什么我需要在脚本中指定单个项目?

/**
 * @NApiVersion 2.x
 * @NScriptType UserEventScript
 */

define(['N/workflow', 'N/search', 'N/error', 'N/record'],
    function (workflow, search, error, record) {
        function initiateWorkflow(scriptContext) {
               var workflowInstanceId = workflow.initiate({
                recordType: 'inventoryitem',
                recordId: 35,
                workflowId: 'customworkflow14'
            });
            var inventoryitemRecord = record.load({
                type: record.Type.INVENTORY_ITEM,
                id: 35
            });
        }
        return {
            afterSubmit: initiateWorkflow
        };
    }); 

Okay everyone, very much through the looking glass on this one.
Many thanks to Barmar, Kryton and bknights whose wisdom has helped get me this far.

The script has changed and is now below. I can upload it and generate a script record and it does actually attempt to run, but now I am getting this error:

"type":"error.SuiteScriptError","name":"RCRD_DSNT_EXIST","message":"There are no records of this type.","stack":["createError(N/error)","initiateWorkflow(/SuiteScripts/grn20.js:9)"],"cause":{"type":"internal error","code":"RCRD_DSNT_EXIST","details":"There are no records of this type.","userEvent":"aftersubmit","stackTrace":["createError(N/error)","initiateWorkflow(/SuiteScripts/grn20.js:9)"],"notifyOff":false},"id":"","notifyOff":false,"userFacing":false}

But the record definitely does exist, the ID number and workflow ID are as specified in the workflow.

What else could be causing this problem?

Thank you in advance for any suggestions!

Edit - I have been told that the record ID below should refer to the internal ID of the item, this makes no sense, the workflow I am trying to initiate is designed to change fields on multiple items, why would I need to specify a single item in the script?

/**
 * @NApiVersion 2.x
 * @NScriptType UserEventScript
 */

define(['N/workflow', 'N/search', 'N/error', 'N/record'],
    function (workflow, search, error, record) {
        function initiateWorkflow(scriptContext) {
               var workflowInstanceId = workflow.initiate({
                recordType: 'inventoryitem',
                recordId: 35,
                workflowId: 'customworkflow14'
            });
            var inventoryitemRecord = record.load({
                type: record.Type.INVENTORY_ITEM,
                id: 35
            });
        }
        return {
            afterSubmit: initiateWorkflow
        };
    }); 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

橙味迷妹 2025-02-15 02:55:52

您正在做的事情有几件事。这确实是RTM的情况。

您可能只是试图锻炼API,因此并不真正关心NetSuite的类型,但NetSuite确实如此。它解析了NScriptType注释,并拒绝您的脚本不合格。

用户事件脚本具有类似的形状:


/**
 * @NApiVersion 2.0
 * @NScriptType UserEventScript
 */
define([module list], function(modules...){
    function beforeRecordSubmit(ctx){...} // these functions can use SuiteScript API Modules
    function beforeRecordSubmit(ctx){...}
    function afterRecordSubmit(ctx){...}

// you cannot use Suitescript API Modules outside of the returned functions

return {
    beforeLoad: beforeRecordLoad,
    beforeSubmit: beforeRecordSubmit,
    afterSubmit: afterRecordSumbit
};

});

也是这些行:

workflowTask.recordType = 'INVENTORY_ITEM';
workflowTask.recordId = 'Item';

看起来它们只是充满希望的猜测。如果您已登录NetSuite,所有这些都有在线帮助。

There are several things wrong with what you are doing. This really is a RTM situation.

You may be just trying to exercise the API so don't really care about the type of script but Netsuite does. It parses the NScriptType annotation and is rejecting your script as being non-conforming.

A user event script has a shape like:


/**
 * @NApiVersion 2.0
 * @NScriptType UserEventScript
 */
define([module list], function(modules...){
    function beforeRecordSubmit(ctx){...} // these functions can use SuiteScript API Modules
    function beforeRecordSubmit(ctx){...}
    function afterRecordSubmit(ctx){...}

// you cannot use Suitescript API Modules outside of the returned functions

return {
    beforeLoad: beforeRecordLoad,
    beforeSubmit: beforeRecordSubmit,
    afterSubmit: afterRecordSumbit
};

});

Also these lines:

workflowTask.recordType = 'INVENTORY_ITEM';
workflowTask.recordId = 'Item';

look like they are just hopeful guesses. There is online help for all of this if you are logged in to Netsuite.

在风中等你 2025-02-15 02:55:52

我可以看到两个问题:

  1. 您需要使用define()而不是require()。从下面的NetSuite文档发出的注释:

请注意,此示例脚本使用了要求功能,以便您可以复制
它进入套件调试器并进行测试。您必须使用定义
在入口点脚本中功能(您附加到脚本的脚本
记录和部署)。有关更多信息,请参见SuiteScript 2.x脚本
基础和套件2.x脚本类型。

  1. 您需要在返回块中实现入口点功能。对于此类用户事件脚本,这意味着您需要beforeloadbeforeSubmitaftersubmit

就您的示例而言,您的脚本最终会看起来像这样:

/**
 * @NApiVersion 2.0
 * @NScriptType UserEventScript
 */

define(['N/task'],
    function (task) {
        function workflowTask(scriptContext) {
            task.create({
                taskType: task.TaskType.WORKFLOW_TRIGGER
            });
            workflowTask.recordType = 'INVENTORY_ITEM';
            workflowTask.recordId = 'Item';
            workflowTask.workflowId = 'customworkflow14';
            var taskId = workflowTask.submit();
        }
        return {
            afterSubmit: workflowTask
        };
    }
);

There are 2 issues that I can see:

  1. You need to use define() rather than require(). Note from NetSuite documents below:

Note This sample script uses the require function so that you can copy
it into the SuiteScript Debugger and test it. You must use the define
function in an entry point script (the script you attach to a script
record and deploy). For more information, see SuiteScript 2.x Script
Basics and SuiteScript 2.x Script Types.

  1. You need to implement an entry point function in your return block. For a User Event Script as this is, that means you need one of beforeLoad, beforeSubmit or afterSubmit.

For your example, your script would end up looking something like this:

/**
 * @NApiVersion 2.0
 * @NScriptType UserEventScript
 */

define(['N/task'],
    function (task) {
        function workflowTask(scriptContext) {
            task.create({
                taskType: task.TaskType.WORKFLOW_TRIGGER
            });
            workflowTask.recordType = 'INVENTORY_ITEM';
            workflowTask.recordId = 'Item';
            workflowTask.workflowId = 'customworkflow14';
            var taskId = workflowTask.submit();
        }
        return {
            afterSubmit: workflowTask
        };
    }
);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文