Requirement
We need to automatically add the current user to the Bcc section of the message record.
Solution
/**
 * @NApiVersion 2.1
 * @NScriptType UserEventScript
 */
/*******************************************************************************
 * CLIENTNAME:Cleerline Technology Group
 * CTG-43
 * CTG Project
 *************************************************************************
 * Date : 25-02-2022
 *
 * Author: Jobin & Jismi IT Services LLP
 * Script Description :
 * The script is used to automatically add the current user to the Bcc section of the message record.
 * Date created :25-02-2022
 * Created by: Aranya T R, Jobin & Jismi IT Services LLP
 * REVISION HISTORY
 * Revision 1.0 ${25-02-2022}
 *
 ******************************************************************************/
define(['N/email', 'N/record', 'N/search', 'N/runtime'], (email, record, search, runtime) =>
{
    const beforeLoad = (scriptContext) =>
    {
        if (scriptContext.type === 'create')
            {
                try ``
                {
                    let objRecord = scriptContext.newRecord;
                    let userObj = runtime.getCurrentUser();
                    let mail = userObj.email;
                    log.debug( " Email ID", mail );
                    let userID = userObj.id;
                    log.debug ( " User ID", userID );
                    objRecord.setSublistValue({
                        sublistId: 'otherrecipientslist',
                        fieldId: 'otherrecipient',
                        value: userID,
                        line: 0,
                        ignoreFieldChange: false
                    });
                    objRecord.setSublistValue({
                        sublistId: 'otherrecipientslist',
                        fieldId: 'email',
                        value: mail,
                        line: 0,
                        ignoreFieldChange: false
                    });
                    objRecord.setSublistValue({
                        sublistId: 'otherrecipientslist',
                        fieldId: 'bcc',
                        value: true,
                        line: 0,
                        ignoreFieldChange: false
                    });
                }
                catch(e)
                {
                    log.debug( "exception", e );
                }
            }
    }
    return {beforeLoad}
});