As an Administrator, streamlining tasks through automation can save time and reduce manual errors. One often overlooked feature is the ability to create and attach Notes to records programmatically. Notes are useful for tracking internal communications, flagging important updates, or adding audit trails to transactions.
In this article, we’ll walk through how to use a Scheduled Script in SuiteScript 2.x to automatically generate a Note record and link it to a specific transaction.
Sample Code: Creating and Attaching a Note Record
/**
* @NApiVersion 2.x
* @NScriptType ScheduledScript
*/
define(['N/record'], function(record) {
function execute(scriptContext) {
// Set the title of the note
var recnote = record.create({
type: record.Type.NOTE
});
// Set the title of the note
recnote.setValue({
fieldId: 'title',
value: 'This is your Note'
});
// Set the Note Type (Example: 7 = General Note)
recnote.setValue({
fieldId: 'notetype',
value: 7
});
// Add the note content
recnote.setValue({
fieldId: 'note',
value: 'This transaction has Note'
});
// Link the note to a specific transaction (e.g., Internal ID 15915)
recnote.setValue({
fieldId: 'transaction',
value: 15915
});
// Save the record
recnote.save();
log.debug('Note', recnote);
}
return {
execute: execute
};
});
Upon script execution, a Note record will be created and attached to the specified transaction.
Note: See the SuiteScript Note Records Browser for all internal IDs associated with this record.
The sample code described herein is provided on an “as is” basis, without warranty of any kind, to the fullest extent permitted by law. Oracle + NetSuite Inc. does not warrant or guarantee the individual success developers may have in implementing the sample code on their development platforms or in using their own Web server configurations.
Oracle + NetSuite Inc. does not warrant, guarantee or make any representations regarding the use, results of use, accuracy, timeliness or completeness of any data or information relating to the sample code. Oracle + NetSuite Inc. disclaims all warranties, express or implied, and in particular, disclaims all warranties of merchantability, fitness for a particular purpose, and warranties related to the code, or any service or software related thereto.
Oracle + NetSuite Inc. shall not be liable for any direct, indirect or consequential damages or costs of any type arising out of any action taken by you or others related to the sample code.
Tip: You can modify the filters or add more columns (like status or currency) depending on your reporting needs.
