将 Item Fulfillment 与高级模板合并并通过电子邮件发送给 Netsuite 2.0

Merge an Item Fulfillment with an advanced template and email it Netsuite 2.0

因此,如果没有下面的合并功能,此代码会在保存时发送一封电子邮件,但我终生无法在 Netsuite 2.0 中使用电子邮件合并功能,那么如何将高级 pdf 模板与项目实现合并并通过电子邮件发送?

/**
 *@NApiVersion 2.x
 *@NScriptType UserEventScript
 */
define(['N/email','N/render', 'N/record', 'N/file'],
    function(email, record, file,render) {  
        function afterSubmit(context) {

        function templatemerge() {
         var myMergeResult = render.mergeEmail({
    templateId: 121,
    entity: {
        type: 'employee',
        id: 18040
        },
    recipient: {
        type: 'employee',
        id: 18040
        },
    supportCaseId: 'NULL',
    transactionId: 1176527,
    customRecord: 'NULL'
    });
        }
        templatemerge();

        function sendEmailWithAttachement() {
        var newId =  context.newRecord;
            var emailbody = 'attachment';
            var senderId = 18040;
            var recipientEmail = 'email@email.com';

            email.send({
               author: senderId,
                recipients: recipientEmail,
                subject: 'Item Fulfillments',
                body: emailbody
            });
        }
        sendEmailWithAttachement();
        }
        return {
            afterSubmit: afterSubmit
        };
    });

尝试将第一个函数签名重新排列为 function(email, render, record, file)

它们的顺序可能有误。