You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用N/currentRecord模块获取当前记录ID?(SS2.X)

问题分析与解决方案
  • 你的代码片段缺少SS2.X客户端脚本的核心模块加载结构,且未确保在正确的客户端脚本事件上下文(如pageInit、fieldChanged等函数)中执行。
  • 在NetSuite SS2.X中,N/currentRecord是客户端专属模块,必须通过define语法加载,且仅能在客户端脚本的事件处理函数内调用currentRecord.get()。

修正后的完整代码示例:

define(['N/currentRecord', 'N/log'], function(currentRecord, log) {
    function pageInit(context) {
        var currentRecordObj = currentRecord.get();
        var internalId = currentRecordObj.id;
        log.debug('Internal ID of the current record:', internalId);
    }

    return {
        pageInit: pageInit
    };
});

额外注意事项:

  • 确保脚本类型设置为客户端脚本,并已绑定到目标记录类型(如销售订单、客户等)。
  • 如果是在服务器端用户事件脚本中获取记录ID,直接从context.newRecord.id取值即可,无需使用N/currentRecord模块。

内容的提问来源于stack exchange,提问作者F M FM

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 10:54:56