【问题标题】:Struggling with saving a response file as pdf and attaching it directly to an item fulfillment努力将响应文件保存为 pdf 并将其直接附加到项目履行中
【发布时间】:2018-10-26 19:37:14
【问题描述】:

我目前正在进行一个工作项目,我与我们物流公司的一个团队合作整合我们的货运服务。目前工作流程的方式(顺便说一下,这是一个用户事件脚本),即在项目履行期间,在自定义选项卡中收集装运所需的信息.我们有一个用作报价选择器的 Suitelet,因此当单击我们创建的“获取报价”按钮时,我们会得到一个包含各种运营商费率的价格表。 在提交发生之前,数据不会发送到他们的系统,当发生这种情况时,我们会将相关数据转换为提单,这是返回的对象。 目前,我们将返回的pdf设置为保存到文件柜中的特定文件夹,但该文件与交易记录没有直接关联。 我正在尝试使用“mediaitem”字段通过通信选项卡内的文件子选项卡直接将 pdf 附加到记录。我尝试将附件接收文件夹设置为目的地,而不是我们在文件柜中创建的自定义“货运提单”,但这不会将其附加到实际记录中。 下面是我们的导入代码的 sn-p (我已对其进行了更改以避免共享确切的代码),它当前将“BOL”pdf 文件保存到我们的文件柜中:

        ***//above this is the post containing API key and etc***
        if (response.code != 200) {
        var responseBody = JSON.parse(response.body);
        log.error ({
            title: 'order #' + sonum + ' shipment import: ' + response.code,
            details: responseBody.Message
        });
        log.error ({
            title: 'order #' + sonum + ' shipment import messageBody',
            details: JSON.stringify(messageBody)
        });
        return;
    }
    //save BOL to Freight BOL folder in File Cabinet
    var bolFile = saveBOL(response);
    var fileId = bolFile.save();


  } catch (e) {
    log.error ({
      title: 'order #' + sonum + ' error: ' + e.name,
      details: e.message
    });
    log.error ({
      title: 'order #' + sonum + ' DLS Import messageBody',
      details: messageBody
    });
  }
}

function saveBOL(response){
  var responseBody = JSON.parse(response.body);
    var bolFile = file.create({
      name: responseBody.FileName,
      fileType: file.Type.PDF,
      contents: responseBody.FileBytes,
      folder: //folderidishere,
      isOnline: false
    });

  var fileId = bolFile.save();
  return bolFile;

}

我很难通过文档或 SuiteAnswers 找到有关通过 SuiteScript 2.0 将文件保存为订单的附件的任何内容。任何建议/帮助将不胜感激!

【问题讨论】:

    标签: javascript netsuite suitescript2.0


    【解决方案1】:

    使用 N/record 模块的 attach 方法。

        var id = record.attach({
        record: {
            type: 'file',
            id: bolFile
        },
        to: {
            type: 'itemfulfillment',
            id: <internalid of item fulfillment>
        }
    

    【讨论】:

    • 谢谢!我对此确实有一个问题,是否有一种最好的方法来封装正在创建的项目履行的 id?我实际上是一名 C# 开发人员,这是我使用 JavaScript 的第一次实际体验。任何关于好的学习材料的建议,或者只是一般的提示将不胜感激!
    猜你喜欢
    • 2021-11-24
    • 1970-01-01
    • 1970-01-01
    • 2017-06-12
    • 1970-01-01
    • 2017-10-23
    • 1970-01-01
    • 2015-08-28
    • 2014-04-15
    相关资源
    最近更新 更多