Error when send email in suite script 2.0
Hi All , I got this error (email.send is not a function) when i apply this client script:
/**
* @NApiVersion 2.x
* @NScriptType ClientScript
*/
define([‘N/runtime’, ‘N/email’], function(runtime, email) {
function pageInit(context) {
if (context.mode === ‘edit’) {
var message = “you dont have phonenumber!”;
var phone = context.currentRecord.getValue({
fieldId: ‘phone’
});
if (!phone) {
alert(message);
}
}
}
function fieldChanged(context) {
var record = context.currentRecord;
var myUser = runtime.getCurrentUser().name;
try {
var myrec = record.getValue({
fieldId: ‘custbody_sor_ordercategory’
});
if (myrec == 1) {
record.setValue({
fieldId: ‘custbody_sor_temptest’,
value: myUser
});
} else {
record.setValue({
fieldId: ‘custbody_sor_temptest’,
value: null
});
}
} catch (e) {
console.log(‘ERROR’, JSON.stringify(e));
}
}
function sendemail() {
var userid = runtime.getCurrentUser().user;
var useremail = runtime.getCurrentUser().email;
email.send({
author: userid,
recipients: useremail,
subject: ‘Test’,
body: ‘my first email’,
attachments: null,
relatedRecords: null
});
}
return {
pageInit: pageInit,
fieldChanged: fieldChanged,
saveRecord: sendemail
};
});
There’s nothing obviously wrong. When do you get the error?
did it work?
Thanks i remove N/runtime ,module and it works thank u