RE: Set Default Email Template

Is there a way to set the email template on a custom record? 

I have created a custom record type, but when I click the email button on the form I have to manually select the email template every time.  Is there a way to do this in SuiteScript 2.0?

RE: Set Default Email Template

PaulSalkeld1969 Rookie Asked on October 10, 2023 in How To's.

Is this Email Message located to a subtab? If so, I don’t think you can’t set this.

on October 10, 2023.
Add Comment
3 Answers

Yes, there is a way to set the email template on a custom record in SuiteScript 2.0. You can use the following steps:

  1. Load the custom record using the N/record.load() method.
  2. Set the emailTemplate property of the record to the internal ID of the email template that you want to use.
  3. Save the record using the N/record.submit() method.

For example, the following code snippet shows how to set the email template for a custom record with the internal ID of 12345:

const record = N/record.load({
  type: 'customrecord_my_custom_record_type',
  id: 12345
});

record.emailTemplate = 54321; // Internal ID of the email template

N/record.submit(record);

You can also use SuiteScript to set the email template for a custom record on creation or update. For example, the following code snippet shows how to set the email template for a custom record when it is created:

const record = N/record.create({
  type: 'customrecord_my_custom_record_type',
  defaultValues: {
    emailTemplate: 54321 // Internal ID of the email template
  }
});

N/record.submit(record);

Or, you can use SuiteScript to set the email template for a custom record when it is updated:

const record = N/record.load({
  type: 'customrecord_my_custom_record_type',
  id: 12345
});

if (!record.emailTemplate) {
  record.emailTemplate = 54321; // Internal ID of the email template
}

N/record.submit(record);

By using SuiteScript to set the email template for a custom record, you can automate the process and save yourself time.

Beginner Answered on October 10, 2023.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.