Are you getting WRONG_PARAMETER_TYPE Error in Netsuite's Suite Script 2.0 while sending email?
Error on Email in Suite Script 2.0 |
You started working on Suitescript 2.0 and everything was good until you got error "WRONG_PARAMETER_TYPE" and you are not able to figure out why.
I got linkedin message where user asked me about below error while sending email to employee.
{"type":"error.SuiteScriptError","name":"WRONG_PARAMETER_TYPE","message":"Wrong parameter type: options.entity is expected as object. ","stack":["createError(N/error)","execute(/SuiteScripts/yourSuitesScriteName.js:lineNoWillComeHere)","createError(N/error)"],"cause":{"name":"WRONG_PARAMETER_TYPE","message":"Wrong parameter type: options.entity is expected as object. "},"id":"","notifyOff":false}
Everything in code is looking good , in debugs all values were coming correctly, Even values were not blank and as mentioned script was showing entity has object, still issue was not solved.
Code which has problem:
vendorId is coming from results.
var myMergeResult = render.mergeEmail({
templateId: 7,
entity: {
type: 'employee',
id: vendorId
}
});
Solution:
In code above type is string type and id accept integer, problem here was values were coming as String not as Integer.
Here vendorId should be parsed to Integer value, there are two ways to parse it, wither use parseInt or use code which is mentioned in Blog post here
var myMergeResult = render.mergeEmail({
templateId: 7,
entity: {
type: 'employee',
id: parseInt(vendorId)
}
});
That is all you need, if you are also seeing this issue please try this if issue still exist then let us know.
Thanks
Netsuite Guru
Download Netsuite Guru Android App
Follow Me on Linkedin
Our FB Page
I don't usually put out comments in the Web but you saved me here. Thank you.
ReplyDeleteThank you so much for such a nice comment.
DeleteThanks a lot, it saved my time...
ReplyDeleteWhen I do query I get same error, but there is no fix that I could find. Stack message is "Wrong parameter type: condition is expected as Condition."
ReplyDeleteHi
DeleteDid you tried to change it to Integer? Try parseInt() method and let us know.
As we mentioned, " In code above type is string type and id accept integer, problem here was values were coming as String not as Integer."