简体   繁体   English

NetSuite SuiteScript 1.0电子邮件附件

[英]NetSuite SuiteScript 1.0 email attachment

I am fairly new to NetSuite scripting and have the following issue. 我对NetSuite脚本非常陌生,并且遇到以下问题。

I am trying to send an email from SuiteScript 1.0. 我正在尝试从SuiteScript 1.0发送电子邮件。 The Script is linked to the AFTER SUBMIT function of Sales Orders. 脚本链接到销售订单的AFTER SUBMIT功能。

My code: 我的代码:

function OnAfterSubmit(record) {
    var fromId = -5; //Authors' Internal ID
    var sbj = 'subject';
    var msg = '';

    //load File from netSuite Document Repository with ID of 123
    var orderid = nlapiGetRecordId();
    var search = nlapiSearchRecord('salesorder', orderid);
    var fileObj = nlapiLoadRecord(search.getRecordType(), search.getId());
    //var detail = getOrderDetail(fileObj);
    //Single Attachment - Attach File ID 123
    //nlapiSendEmail(fromId, 'xyz@test1.example', sbj, msg, null, null, null, fileObj);

    //multiple Attachments
    //build Array of file objects
    var attach = [fileObj];
    //pass attach array as attachment parameter
    nlapiSendEmail(fromId, 'charl@email.example', sbj, msg, null, null, null, attach);
}

I am trying to send the record that has been created by the user, via email. 我正在尝试通过电子邮件发送用户创建的记录。

The record parameter doesn't seem to be what I expect. record参数似乎不是我期望的。 The error I receive says "invalid search". 我收到的错误消息为“无效搜索”。 When I used record.id , the error simply said "id". 当我使用record.id ,错误只是说“ id”。 I also tried record.internalId . 我也尝试了record.internalId

function OnAfterSubmit(type) {

    var fromId = -5; //Authors' Internal ID
    var toEmail = 'charl@email.example';
    var sbj = 'subject';
    var msg = '';

    var newRecord = nlapiGetNewRecord();
    var recordAsJSON = JSON.stringify(newRecord);
    var fileObj = nlapiCreateFile('salesorder.json', 'JSON', recordAsJSON);

    nlapiSendEmail(fromId, toEmail, sbj, msg, null, null, null, fileObj);

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM