Dhananjay Donthula
11/05/2019, 4:16 PM/**
*@NApiVersion 2.x
*@NScriptType Suitelet
*/
// this creates a Suitelet form that lets you write and send an email
define(['N/ui/serverWidget', 'N/email', 'N/runtime'],
function(ui, email, runtime) {
function onRequest(context) {
if (context.request.method === 'GET') {
var form = ui.createForm({
title: 'Demo Suitelet Form'
});
form.clientScriptModulePath = "./helloWorld.js";
var subject = form.addField({
id: 'subject',
type: ui.FieldType.TEXT,
label: 'Subject'
});
subject.layoutType = ui.FieldLayoutType.NORMAL;
subject.breakType = ui.FieldBreakType.STARTCOL;
subject.isMandatory = true;
var recipient = form.addField({
id: 'recipient',
type: ui.FieldType.EMAIL,
label: 'Recipient email'
});
recipient.isMandatory = true;
var message = form.addField({
id: 'message',
type: ui.FieldType.TEXTAREA,
label: 'Message'
});
message.displaySize = {
width: 60,
height: 10
};
form.addSubmitButton({
label: 'Send Email'
});
form.addButton({
id: 'custpage_sample_button',
label: 'Sample Button',
functionName: 'customSubmit'
});
context.response.writePage(form);
} else {
var request = context.request;
email.send({
author: runtime.getCurrentUser().id,
recipients: request.parameters.recipient,
subject: request.parameters.subject,
body: request.parameters.message
});
}
}
return {
onRequest: onRequest
};
});
erictgrubaugh
11/05/2019, 4:23 PMDhananjay Donthula
11/05/2019, 4:24 PMerictgrubaugh
11/05/2019, 4:26 PMDhananjay Donthula
11/05/2019, 4:27 PMDhananjay Donthula
11/05/2019, 4:28 PMDhananjay Donthula
11/05/2019, 4:30 PMDhananjay Donthula
11/05/2019, 4:33 PMerictgrubaugh
11/05/2019, 4:35 PMerictgrubaugh
11/05/2019, 4:36 PMSuiteScript 2.0 Custom Modules
erictgrubaugh
11/05/2019, 4:36 PMDhananjay Donthula
11/06/2019, 6:09 AMNairolf
11/19/2019, 12:28 AMNairolf
11/24/2019, 4:56 PMerictgrubaugh
11/24/2019, 6:05 PMerictgrubaugh
11/24/2019, 6:07 PMfunctionName
property is not used to pass data into the click handler function. The Suitelet and the Client Script don't share any context, so my typical approach is to store the relevant data on the record, in the cache, or in the session (in order of preference).Nairolf
11/24/2019, 6:10 PMerictgrubaugh
11/24/2019, 6:12 PMNairolf
11/24/2019, 9:32 PM