This topic contains 14 replies, has 0 voices, and was last updated by david.smith 7 years, 6 months ago.
-
AuthorPosts
-
kentroylance- Contributions: 0
- Level 1
- ☆
I am trying to use the nlapiCreateEmailMerger feature to merge an email template, and I just can't figure out why when I call nlapiCreateEmailMerger with a email template id, it throws an error of is not defined. I created the email template, and I am using the right id, but something is not right. Is there something specific I have to do with the email template to get this to work?
This is a cached copy. Click here to see the original post. -
erictgrubaugh- Contributions: 0
- Level 1
- ☆
Can you post your code?
-
kentroylance- Contributions: 0
- Level 1
- ☆
What has me stumped big time is that this code is nearly identical to the code from this article: https://netsuite.custhelp.com/app/an…mail/related/1
Its acting as if I don't have something configured correctly.
var recordid = nlapiGetRecordId(); // Load Record ID
var recipient = nlapiGetFieldValue('email');
var emailMerger = nlapiCreateEmailMerger('3'); // Initiate Email Merger – failing on this line
emailMerger.setTransaction(recordid); // Set the ID of the transaction where you are going to fetch the values to populate the variables on the template
var mergeResult = emailMerger.merge(); // Merge the template with the email
var emailSubject = mergeResult.getSubject(); // Get the subject for the email
var emailBody = mergeResult.getBody(); // Get the body for the email
nlapiSendEmail(nlapiGetUser(), recipient, emailSubject, emailBody, null, null, null, null);
-
erictgrubaugh- Contributions: 0
- Level 1
- ☆
And what type of script is this?
According to NetSuite Help:
The nlobjEmailMerger object is supported in all server-side scripts.
If you are attempting to merge in a Client Script, perhaps this API is not available there.
-
kentroylance- Contributions: 0
- Level 1
- ☆
SuiteScript. Many of the api calls I make in the script seem to work fine. There is something odd about the nlapiCreateEmailMerger function. Is there another way to do this that works?
-
erictgrubaugh- Contributions: 0
- Level 1
- ☆
I know it's SuiteScript, but what Script Type is it? If it is a Client Script,
nlapiCreateEmailMerger
may not be defined there; if that is the case, you may need to move the email merge portion of your code to a User Event that runs after the record is saved.If it is not a Client Script, then I have no clue what would be going wrong, and it may be worth filing a case with NS Support then.
-
kentroylance- Contributions: 0
- Level 1
- ☆
I have tried both Suitelet and Restlet, and both don't seem to work. I haven't tried Client yet. I guess that is worth trying. Kind of hard to believe this type of functionality is not available as a Suitelet or Restlet.
-
kentroylance- Contributions: 0
- Level 1
- ☆
Looks like Client type doesn't work either. Getting the same error: undefined. ReferenceError: nlapiCreateEmailMerger is not defined. How do I find out where it is defined?
-
david.smith- Contributions: 0
- Level 1
- ☆
What record type are you attaching this script to? Is it a transaction or something else?
-
kentroylance- Contributions: 0
- Level 1
- ☆
For the email template, the Record Type is Entity (not sure if that is right or not). This is for a customer record.
-
david.smith- Contributions: 0
- Level 1
- ☆
var emailMerger = nlapiCreateEmailMerger('3'); // Initiate Email Merger – failing on this line
If you're failing on the line that creates the email merger then I would check your template. Make sure it's a scriptable template.
-
kentroylance- Contributions: 0
- Level 1
- ☆
How do I know if it is a scriptable template? I don't see any fields that enable it as scriptable.
-
kentroylance- Contributions: 0
- Level 1
- ☆
I followed this article exactly: https://netsuite.custhelp.com/app/an…mail/related/1, so there must be some small detail that I am missing.
-
kentroylance- Contributions: 0
- Level 1
- ☆
Unless I am missing something, these templates must be created from the Setup > Company > Email > System Email Templates. That is very misleading, since I thought you could create email templates from Documents > Templates > Email Templates. I didn't necessarily want to create System Email Templates. https://system.na2.netsuite.com/app/…2.html&whence=
david.smith replied on 02/21/2017, 09:32 AM: System email templates are not supported. -
david.smith- Contributions: 0
- Level 1
- ☆
How did you get "3" for your ID (just trying to cover everyting)? The internalid can be found in the URL when you edit the email template. It will be something like this: /app/crm/common/merge/emailtemplate.nl?id=19&e=T
If that is the line you're failing on it has to do with either the record type not supported (customer records are) or the template you're trying to use.
-
AuthorPosts
You must be logged in to reply to this topic.