Does your Custom Record have `Show Notes` enabled?
# suitescript
e
Does your Custom Record have
Show Notes
enabled?
d
let me see. I am able to add Notes manually so, I expected it would have it.
YES SHOW NOTES IS CHECKED
Replied in Thread @erictgrubaugh, thanks for your thoughts!
e
2.0?
d
YES
e
Make sure the
recordtype
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
)
I have this function which is working in a Production environment right now.
context.recordType
comes in as`421` , for example.
d
hmmm
Copy code
require(['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	}),
	});
});
My SNIPPET for Sample 2.5 passed in '807' as string this time and still created all three but none appear on the Custom Record
Notes in List view after create via DEBUG
Only the note I made manually is visible on the Custom Record.