Monday, January 7, 2019

Update Case Messages via Script

To update the Message field on a Case Record, create a search for the messages of the case record and get the internal id of the specific message needed, for example:

var filter = new Array();
                        
filter[0] = new nlobjSearchFilter('internalidnumber', null, 'equalto', 3118);

var columns = new Array();

columns[0] = new nlobjSearchColumn('subject', 'messages', null); //using join: message.subject column
columns[1] = new nlobjSearchColumn('messageDate', 'messages', null); //using join: message.messageDate column
columns[2] = new nlobjSearchColumn('internalId', 'messages', null); //using join: message.internalId column
columns[3] = new nlobjSearchColumn('messageType', 'messages', null); //using join: message.messageType column

notice the above mentioned column 2, there is the internal id needed and used in the code below:

var nlobjMsg = nlapiLoadRecord('message', msgInternalID);
nlobjMsg.setFieldValue('message', 'TEST');
nlapiSubmitRecord(nlobjMsg);

Reference the internal ID on the search on the second code snippet.

No comments:

Post a Comment