Message

A message is used to record correspondence you have with a specific business. Use the message record to add an email message to an existing customer, contact, or opportunity record. After an email message has been added to a record, any related emails are automatically attached to the same record and to any recipients of the original email.

To work with the message record, sublist of recipients, and to send email, use the N/email Module.

For help working with this record in the user interface, see Sending Email from Records.

The internal ID for this record is message.

See the SuiteScript Records Browser for all internal IDs associated with this record.

Note:

For information about using the SuiteScript Records Browser, see Working with the SuiteScript Records Browser in the NetSuite Help Center.

For information about scripting with this record in SuiteScript, see the following:

Supported Script Types

The message record is scriptable in server SuiteScript only.

Supported Functions

For information about sending email from a record, see Sending Email from Records. Note that there are also other types of messages, but those are not supported. In the message that you are creating, you can set all supported fields for email messages before saving. After you save the new message, there are restrictions applied to it. You cannot edit the existing message. It is possible to delete an existing message, if the permissions for the user are set to allow this type of operation. However, you should not delete an existing message because it can cause email communication threads to be displayed incorrectly.

Usage Notes

Code Sample

The following SuiteScript 2.0 snippet shows how to add an email address to the cc line of a new message, when working in standard (deferredDynamic) mode.

Note:

Some of the values in this sample are placeholders. Before using this sample, replace all hard-coded values, such as IDs and file paths, with valid values from your NetSuite account. If you run a script with an invalid value, the system may throw an error.

          /**
 * @NApiVersion 2.x
 */

require(['N/record'], function(record) {
      function makeMessage(){
         var messageRec = record.create ({
            type: record.Type.MESSAGE,
            isDynamic: true
      });

      messageRec.setValue({
         fieldId: 'subject',
         value: 'Test Message'
      });

      messageRec.setValue({
         fieldId: 'author',
         value: 15 //internal id of author name
      });

      messageRec.setValue({
         fieldId: 'authoremail',
         value: 'name@example.com'
      });

      messageRec.setValue({
         fieldId: 'recipient', 
          value: 164 //internal ID of recipient 
      });

      messageRec.setValue({
         fieldId: 'recipientemail',
          value: 'name@example.com'
      });

      messageRec.setValue({
         fieldId: 'cc',
          value: 'name@example1.com, name@example2.com'

      messageRec.setValue({
         fieldId: 'bcc',
    value: 'name@example3.com'
      });

      messageRec.setValue({
         fieldId: 'message',
         value: 'test message'
      });

      var custMessage = messageRec.save();

      log.debug({title: 'message', details: custMessage   
      });
      }
      makeMessage();
      });
   });
... 

        

Related Topics

General Notices