David B
11/09/2021, 9:14 AMrender.mergeEmail()
(link)
In my email template (record type = Transaction) I can specify fields from the customer (such as customer.subsidiary
). But how do I pass the customer record into mergeEmail()
?
I've tried this, but get error "Wrong parameter type: options.recipient is expected as object."David B
11/09/2021, 9:19 AMrecipient: { type: 'lead', id: 543 }
I've tried types lead
and prospect
also. I get the same error for for lead
, and for prospect
I get:
"You have entered an invalid type argument: prospect"NElliott
11/09/2021, 10:23 AMbattk
11/09/2021, 1:01 PMfunction doMergeEmail(options) {
var undef = undefined;
var templateId =
options !== undef && options !== null && options.templateId !== undef
? options.templateId
: undef;
utilityFunctions.checkArgs(
[templateId],
["options.templateId"],
"render.doMergeEmail"
);
var mergerObj = invoker(renderApi, "nlapiCreateEmailMerger", [templateId]);
if (options.entity) {
checkRecordRefParameter(options.entity, "options.entity");
invoker(mergerObj, "setEntity", [options.entity.type, options.entity.id]);
}
if (options.recipient) {
checkRecordRefParameter(options.recipient, "options.recipient");
invoker(mergerObj, "setRecipient", [
options.recipient.type,
options.recipient.id,
]);
}
if (options.customRecord) {
checkRecordRefParameter(options.customRecord, "options.customRecord");
invoker(mergerObj, "setCustomRecord", [
options.customRecord.type,
options.customRecord.id,
]);
}
if (options.supportCaseId) {
if (!util.isNumber(options.supportCaseId)) {
utilityFunctions.throwSuiteScriptError(
error.Type.WRONG_PARAMETER_TYPE,
"options.supportCaseId",
"number"
);
}
invoker(mergerObj, "setSupportCase", [options.supportCaseId]);
}
if (options.transactionId) {
if (!util.isNumber(options.transactionId)) {
utilityFunctions.throwSuiteScriptError(
error.Type.WRONG_PARAMETER_TYPE,
"options.transactionId",
"number"
);
}
invoker(mergerObj, "setTransaction", [options.transactionId]);
}
var mergeResultObj = invoker(mergerObj, "merge");
return new EmailMergeResult(mergeResultObj);
}
battk
11/09/2021, 1:02 PMfunction checkRecordRefParameter(recordRefObj, name) {
if (
!recordRefObj ||
!utilityFunctions.isObject(recordRefObj) ||
!recordRefObj.id ||
!util.isNumber(recordRefObj.id) ||
!recordRefObj.type ||
!util.isString(recordRefObj.type)
)
utilityFunctions.throwSuiteScriptError(
error.Type.WRONG_PARAMETER_TYPE,
name,
"object"
);
}
David B
11/09/2021, 7:57 PM!util.isNumber(recordRefObj.id)
the id I was using was a string from getValue()
(should have paid more attn to the RecordRef definition that explicitly says id is a number)
Where'd you get the function? I couldn't find it loaded in the browserbattk
11/09/2021, 8:04 PMbattk
11/09/2021, 8:04 PM