将项目履行与高级模板合并,并通过电子邮件发送至Netsuite 2.0

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

本文关键字:电子邮件 Netsuite 项目 高级模 合并      更新时间:2023-09-26

因此,如果没有下面的合并功能,这段代码在保存时会发送一封电子邮件,但我一辈子都无法在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)

它们可能顺序不对。