This topic contains 14 replies, has 0 voices, and was last updated by david.smith 7 years, 9 months ago.
-
AuthorPosts
-
February 21, 2017 at 6:15 am #21825
kentroylanceI 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. -
February 21, 2017 at 6:43 am #21826
erictgrubaughCan you post your code?
-
February 21, 2017 at 7:50 am #21827
kentroylanceWhat 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);
-
February 21, 2017 at 7:51 am #21828
erictgrubaughAnd 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.
-
February 21, 2017 at 8:03 am #21829
kentroylanceSuiteScript. 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?
-
February 21, 2017 at 8:05 am #21830
erictgrubaughI 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.
-
February 21, 2017 at 8:15 am #21831
kentroylanceI 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.
-
February 21, 2017 at 8:39 am #21832
kentroylanceLooks 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?
-
February 21, 2017 at 8:49 am #21833
david.smithWhat record type are you attaching this script to? Is it a transaction or something else?
-
February 21, 2017 at 8:57 am #21834
kentroylanceFor the email template, the Record Type is Entity (not sure if that is right or not). This is for a customer record.
-
February 21, 2017 at 9:02 am #21835
david.smithvar 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.
-
February 21, 2017 at 9:11 am #21836
kentroylanceHow do I know if it is a scriptable template? I don't see any fields that enable it as scriptable.
-
February 21, 2017 at 9:18 am #21837
kentroylanceI followed this article exactly: https://netsuite.custhelp.com/app/an…mail/related/1, so there must be some small detail that I am missing.
-
February 21, 2017 at 9:28 am #21838
kentroylanceUnless 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.
-
February 21, 2017 at 9:31 am #21839
david.smithHow 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.