Course: SuiteScript 2.0: Extend Netsuite with JavaScript Beginner Help
I’m on the SuiteScript Modules lesson of this course and following along. I thought I’d copied the instructor’s code exactly, but it’s not creating a new phone call when a new employee is created, even though the script is saved in Netsuite. Does anyone see any problems with this script?
/** * @NApiVersion 2.0 * @NScriptType UserEventScript */ define(['N/record'], /** * * @param record */ function(record){ return { afterSubmit: function (context) { log.debug('Hello World'); // var employee = context.newRecord; var empCode = employee.getValue('custentity_sdr_employee_code'); var supervisorId = employee.getValue('supervisor'); log.debug('Employee Code', empCode); log.debug('Supervisor ID', supervisorId); if (context.type == context.UserEventType.CREATE){ var phoneCall = record.create({ type: record.Type.PHONE_CALL }); phoneCall.setValue('title', 'Call HR for benefits'); phoneCall.setValue('assigned', employee.id); phoneCall.save(); } } }; });
I had wrote a great response but was not logged in and it’s now gone.
https://www.youtube.com/watch?v=-fh7UiSuzMQ
https://suiterep.com/2020/10/22/suitescript-2-0-user-event-script-after-submit/
If you do nothing but copy and paste code, keep doing it, you might get lucky. But way better to understand what you are doing and take some pride in your work.
Best,
Troy
phoneCall.save log the return value from this, are you at least seeing the hello world?



