1
votes

Hi I'm trying to find an example of linking a user note to an existing supportcase record in a Netsuite RESTlet script. I'm fairly new to javascript and netsuite, so trying to figure this out myself is running me up the wall.

Thanks in advance.

2
Could you post what you have started with already? If it helps I have a YouTube channel for SuiteScript beginners: youtube.com/c/StoicSoftware - erictgrubaugh
thanks Eric, I hadn't started a script for this yet, I've implemented working scripts for creating cases, updating, searching etc. But couldn't find anything online about user notes and linking to cases. I'll check out your channel, thanks! - Clinton Tonge

2 Answers

1
votes

Here is a block of code used to create a note and attach to an entity record. It would be similar to your needs on the support case record. Hope this helps.

// new note
        var noteObj = {
                "note": decodeURIComponent( data[param] ),
                "title": decodeURIComponent( data[param+"_title"] )
        }
        // set the note entity to the lead
        var noteRecord = record.create({
            type: record.Type.NOTE
        }).setValue({
            fieldId: 'entity',
            value: recordId
        }).setValue({
            fieldId: 'note',
            value: decodeURIComponent( noteObj.note )
        }).setValue({
            fieldId: 'title',
            value: decodeURIComponent( noteObj.title )
        }).save({
            enableSourcing: false,
            ignoreMandatoryFields: true
        });
0
votes

Thanks for the replies on this. Here is my working script using SuiteScript 1.0:

function newNote(datain)
{
    // new note
    var record = nlapiCreateRecord('note');
    // set the note activity value to the case id
    record.setFieldValue('activity',datain.recordID);
    record.setFieldValue('note',datain.note );
    record.setFieldValue('direction',1 );
    record.setFieldValue('notetype',9 );
    record.setFieldValue('title',datain.title );
    var recordId = nlapiSubmitRecord(record);
    nlapiLogExecution('DEBUG','id='+recordId);
    var nlobj = nlapiLoadRecord('note',recordId);
    return nlobj;

}