D. Orozco
04/09/2020, 6:23 PMD. Orozco
04/09/2020, 6:29 PMrequire(['N/runtime',
'N/search',
'N/render',
'N/record'],
function(runtime, search, render, record)
{
function addUserNote (options) {
var note = record.create({ 'type' : record.Type.NOTE });
var finalContent = '';
if ('title' in options) {
finalContent += runtime.getCurrentScript().id;
finalContent += ':';
} // else this will become the title so skip
finalContent += runtime.getCurrentScript().deploymentId;
if ('note' in options) {
finalContent += ' ';
finalContent += options['note'];
} // else no note but use script details
if ('transactionID' in options) {
note.setValue({ 'fieldId' : 'transaction', 'value' : options['transactionID'] });
} else if ('customerID' in options) {
note.setValue({ 'fieldId' : 'entity', 'value' : options['customerID'] });
} else if ('recordID' in options) {
note.setValue({ 'fieldId' : 'record', 'value' : options['recordID'] });
if ('recordType' in options) note.setValue({ 'fieldId' : 'recordType', 'value' : options['recordType'] });
}
if (!('transactionID' in options) // transaction user-note
&& !('customerID' in options) // customer user-note
&& !('recordID' in options) // custom-record user-note
&& !('recordType' in options)) throw finalContent; // should not happen but just as defensive code
if (finalContent.length > 4000) {
finalContent = finalContent.substring(0, 4000);
} // else the entire note fits the maximum User Note memo length
note.setValue({ 'fieldId' : 'note', 'value' : finalContent });
if (!('title' in options)) { // default the title
options['title'] = runtime.getCurrentScript().id
} // else use the title provided
note.setValue({ 'fieldId' : 'title', 'value' : options['title'] });
note.setValue({ 'fieldId' : 'direction', 'value' : 1 }); // i.e. "Incoming"
note.setValue({ 'fieldId' : 'notetype', 'value' : 7 }); // i.e. "User" - Setup > Sales > CRM Lists > New > Note Type
return note.save();
}
var snapshotID = 3380709;
var recordType = 'customrecord_v4_render_snapshot';
var recordTypeID = 807;
addUserNote({
'title' : 'Sample 1',
'recordType' : recordType,
'recordID' : snapshotID,
});
addUserNote({
'title' : 'Sample 2',
'recordType' : recordTypeID,
'recordID' : snapshotID,
});
addUserNote({
'title' : 'Sample 3',
'recordID' : record.load({ // reuse custom record
'type' : recordType,
'id' : snapshotID }),
});
});
D. Orozco
04/09/2020, 6:32 PMD. Orozco
04/09/2020, 6:35 PMerictgrubaugh
04/09/2020, 6:41 PMrecordtype
must be numeric, not the string "customrecord_blah"
, and record
must be a string, "3380709"
not 3380709
.
Force snapshotID
to be a string, use recordTypeID
, and it should workD. Orozco
04/09/2020, 6:45 PMD. Orozco
04/09/2020, 6:45 PMerictgrubaugh
04/09/2020, 6:45 PMD. Orozco
04/09/2020, 6:56 PMD. Orozco
04/09/2020, 6:57 PMD. Orozco
04/09/2020, 7:06 PMbattk
04/09/2020, 11:13 PMbattk
04/09/2020, 11:15 PMrecordtype
to the internal id number of the custom record type and the record
to the internal id number of the particular custom recorderictgrubaugh
04/09/2020, 11:18 PMrecord
must be a string in my experienceerictgrubaugh
04/09/2020, 11:18 PM"123"
battk
04/09/2020, 11:19 PMerictgrubaugh
04/09/2020, 11:21 PMerictgrubaugh
04/09/2020, 11:21 PM