如何在NetSuite中获取包含System Notes的记录列表?
在NetSuite中获取所有包含System Notes的记录列表的可行方法
一、原生保存搜索(无需代码)
这是针对单一记录类型最直接的查询方式:
- 进入
Lists > Search > Saved Searches > New,选择目标记录类型(比如客户、供应商)。 - 在「Criteria」标签下,点击「Add Filter」,搜索并选择
System Notes: Internal ID,设置筛选条件为Is Not Empty。 - 切换到「Results」标签,添加需要展示的字段(比如记录ID、名称),保存并运行搜索,即可得到该记录类型下所有带有System Notes的记录。
二、SuiteScript 开发(支持跨记录类型/自动化)
如果需要跨多个记录类型查询,或者要整合到自动化流程中,SuiteScript是更灵活的方案:
以下是SuiteScript 2.x的示例代码,用于获取指定记录类型中包含System Notes的记录信息:
function getRecordsWithSystemNotes(recordType) { // 创建搜索,筛选存在System Notes的记录 const noteSearch = search.create({ type: recordType, filters: [ ['systemnotes.internalid', 'noneof', '@NONE@'] ], columns: ['internalid', 'entityid'] // 按需添加需要的字段 }); // 分页获取结果,避免触发治理限制 const results = []; let start = 0; let pageResults; do { pageResults = noteSearch.run().getRange({start: start, end: start + 1000}); results.push(...pageResults); start += 1000; } while (pageResults.length === 1000); // 格式化返回结果 return results.map(result => ({ id: result.getValue('internalid'), name: result.getValue('entityid') })); } // 调用示例:获取所有带System Notes的客户记录 const customerRecords = getRecordsWithSystemNotes('customer'); log.debug('Records with System Notes', customerRecords);
- 若要遍历所有支持System Notes的记录类型,可以先通过
search.getAllRecordTypes()获取记录类型列表,再逐个调用上述函数,但需注意权限和治理限制,避免执行超时。
三、关键注意事项
- 并非所有NetSuite记录类型都支持System Notes,部分自定义记录可能未启用该功能,需提前确认目标记录类型的配置。
- 原生保存搜索仅支持单一记录类型查询,跨类型需求必须依赖脚本实现。
- 脚本处理大量数据时,务必分页获取结果,避免超出NetSuite的治理限制(比如并发数、执行时间)。
内容的提问来源于stack exchange,提问作者Maria S
相关产品推荐
相关产品推荐

