I am receiving the error {"type":"error.SuiteScrip...
# ask-stanley-ai
s
I am receiving the error {"type":"error.SuiteScriptError","name":"WRONG_PARAMETER_TYPE","message":"Wrong parameter type: options.entity is expected as object. " when using the mergeEmail method in the render module. I have my entity set up the exact same way it is in the code example on SuiteAnswers, using entity: { type: 'customer', id: customerId }. How do I troubleshoot?
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems like you're encountering an error because the
entity
object you're passing to the
mergeEmail
method is not being recognized as a valid object. This could be due to a few reasons: 1. Incorrect Entity Type: The
type
property of the
entity
object should be one of the following: 'Contact', 'Case', 'Customer', 'Employee', 'Partner', 'Vendor', all transaction types, or all custom records. If you're using 'lead' or 'entity' as the type, it might not be recognized as a valid type. 2. Incorrect Entity ID: The
id
property of the
entity
object should be a valid ID of an existing record in your NetSuite account. If the ID does not exist or is not associated with the specified type, it might cause an error. 3. Incorrect Usage of Null Values: If you're not using certain properties in the
mergeEmail
method, you should omit them instead of setting them to
null
. According to the conversations, setting unused properties to
null
might cause an error. Here's an example of how you might use the
mergeEmail
method:
Copy code
javascript
var mergeResult = render.mergeEmail({
    templateId: 218,
    entity: {
        type: 'customer',
        id: customerId
    }
});
In this example, only the
templateId
and
entity
properties are used. The
entity
object has a
type
of 'customer' and an
id
of
customerId
, which should be a valid ID of a customer record in your NetSuite account. If you're still encountering the error after checking these points, you might need to use a different method to pass data to your email template. One of the conversations suggests using a
TemplateRenderer
to add your data. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.878295898
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.866760254
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.861022949
Please provide your feedback on this answer.
a
If AI Stanley's example doesn't work, first make sure the ID is an integer like 1234, not a string like "1234". If that still doesn't work, I have had success doing it the heavy way and putting a Record object in for Entity (which usually means having to load that record, which is why I call it the heavy way). There might be a lighter way that doesn't require you to load the whole record, but I don't know it yet.
s
The integer was 1000% the issue, thanks so much!!!
👍 1
a
You're welcome 🙂