erictgrubaugh
04/09/2020, 6:25 PMShow Notes
enabled?D. Orozco
04/09/2020, 6:30 PMD. Orozco
04/09/2020, 6:31 PMD. Orozco
04/09/2020, 6:34 PMerictgrubaugh
04/09/2020, 6:34 PMD. Orozco
04/09/2020, 6:35 PMerictgrubaugh
04/09/2020, 6:36 PMrecordtype
value you're passing is the numeric ID for the record type, and not "customrecord_blah"
, and make sure that the record
value you are passing is a string, not a number, i.e. ("123"
not 123
)erictgrubaugh
04/09/2020, 6:39 PMcontext.recordType
comes in as`421` , for example.D. Orozco
04/09/2020, 6:41 PMD. Orozco
04/09/2020, 6:42 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';
addUserNote({
'title' : 'Sample 1',
'recordType' : recordType,
'recordID' : snapshotID,
});
addUserNote({
'title' : 'Sample 2',
'recordType' : 807,
'recordID' : snapshotID,
});
addUserNote({
'title' : 'Sample 2.5',
'recordType' : '807',
'recordID' : snapshotID,
});
addUserNote({
'title' : 'Sample 3',
'recordID' : record.load({ // reuse custom record
'type' : recordType,
'id' : snapshotID }),
});
});
D. Orozco
04/09/2020, 6:42 PMD. Orozco
04/09/2020, 6:43 PMD. Orozco
04/09/2020, 6:43 PM