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

如何创建Saved Search获取InventoryItems关联的文件

解决NetSuite中获取InventoryItems关联文件的Saved Search配置方法

核心思路

要获取InventoryItem关联的文件,需通过File类型的Saved Search,利用三层关联关系(File → Communication Activity → Inventory Item)过滤目标文件,而非从Activity或InventoryItem类型入手。

具体配置步骤

  1. 创建File类型的Saved Search

    • 进入NetSuite后台,导航到Lists > Search > Saved Searches > New,选择File作为搜索类型。
  2. 添加关联过滤条件

    • 切换到Criteria标签页的Standard子标签:
      • 过滤条件1:Attached To: Type → is equal to → Activity
      • 过滤条件2:Attached To: Activity: Type → is equal to → Communication(对应客户在InventoryItem的Activities下Communication标签关联的记录)
      • 过滤条件3:Attached To: Activity: Related Record: Type → is equal to → Inventory Item
      • (可选)若需限定特定InventoryItem,添加Attached To: Activity: Related Record: Internal ID或Attached To: Activity: Related Record: Item ID并设置对应值
  3. 配置返回字段

    • 切换到Results标签页,添加需要的字段:
      • 文件核心字段:Internal ID(用于PHPToolkit下载)、Name、File Size、URL
      • 关联Activity字段:Attached To: Activity: Internal ID、Attached To: Activity: Created Date(可选,用于溯源)
      • 关联InventoryItem字段:Attached To: Activity: Related Record: Internal ID、Attached To: Activity: Related Record: Item ID(用于对应网站商品)
  4. 保存并测试搜索

    • 给Saved Search命名(如Inventory Item Attached Files),点击Save & Run预览结果,确认返回文件关联到目标InventoryItem。

PHPToolkit调用要点

  • 使用FileSearchAdvanced调用已保存的搜索,示例代码片段:
    $search = new FileSearchAdvanced();
    $search->savedSearchId = '123'; // 替换为你的Saved Search ID
    $searchResult = $service->search($search);
    
    // 遍历结果获取文件ID并下载
    foreach ($searchResult->searchResult->recordList->record as $fileRecord) {
        $fileId = $fileRecord->internalId;
        $file = $service->getFile(array('internalId' => $fileId));
        // 将base64编码的文件内容解码后保存到服务器
        file_put_contents('/path/to/your/server/files/' . $fileRecord->name, base64_decode($file->content));
    }
    
  • 确保NetSuite角色拥有File、Activity、Inventory Item的查看权限,以及该Saved Search的执行权限。

内容的提问来源于stack exchange,提问作者Bill Hoisington

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.08 14:25:06