RE: {“type”:”error.SuiteScriptError”,”name”:”UNEXPECTED_ERROR”,”message”:null,”stack”:[“doSendEmail(N/email)”,”(/SuiteScripts/sdr_ue_customer.js:43)”],”c

/**
 * @NScriptType UserEventScript
 * @NApiVersion 2.0
 */
define([‘N/record’, ‘N/email’, ‘N/runtime’, ‘N/task’], function(record, email, runtime, task) {
    return {
        afterSubmit: function(Context) {
            //log.debug(“Hello World”);
            var customer = Context.newRecord;
            var customerId = customer.getValue(‘entityid’);
            var customerEmail = customer.getValue(’email’);
            var salesRepName = customer.getValue(‘salesrep’);
            var couponCode = customer.getValue(‘custentity_sdr_coupon_code’);
            log.audit(‘CUSTOMER ID’, customerId);
            log.audit(‘Customer Email’, customerEmail);
            log.audit(‘SALES REP Name’, salesRepName);
            log.audit(‘COUPON CODE’, couponCode);
            if (Context.type === Context.UserEventType.CREATE) {
                var task = record.create({
                    type: record.type.TASK,
                    defaultValues: {
                        customform: -120
                    }
                });
                task.setValue(‘title’, ‘New Customer Follow-up’);
                task.setValue(‘message’, ‘Please take care of this customer and follow-up with them soon.’);
                task.setValue(‘priority’, ‘HIGH’);
                task.setValue(‘company’, customer.id);
                var salesrep = customer.getValue(‘salesrep’);
                if (salesrep) {
                    task.setValue(‘salesrep’, salesrep);
                }
                task.save();
            }
            var user = runtime.getCurrentUser();
            email.send({
                author: user.id,
                recipients: customer.id,
                subject: ‘Welocome_tO_SuiteDreams’,
                body: ‘Welcome!We are glad for you to be a customer of SuiteDreams.’
            })
        }
    }
});
virtual LIFE Rookie Asked on June 22, 2022 in SuiteScript.
Add Comment
1 Answers

My guess is that you need to switch how you get the customer id.

From:


recipients: customer.id,

To:


recipients: customer.getValue('internalid'),

Rookie Answered on June 22, 2022.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.