Hi
I am posting a part of my M/R script and an error below and have a question if someone could answer for me:
Code:
function reduce(reduceContext)
{
var arr_preApptSurvey = [];
var apptmtId = reduceContext.key;
log.debug('apptmtId', apptmtId);
var customer_id = search.lookupFields({
type: 'calendarevent',
id: apptmtId,
columns: ['company']
});
log.debug('customer_id', customer_id);
var preApptSurveysSearch = search.create({ // This is Line 50, the one that throws error
type: 'customrecord848',
filters: ['custrecord_customer', 'is', customer_id],
columns:
[
search.createColumn({
name: 'id',
sort: search.Sort.ASC,
label: 'ID'
})
]
});
}
Error:
{"type":"error.SuiteScriptError","name":"TypeError","message":"Cannot find function _marshal in object [object Object].","stack":["createError(N/error)"],"cause":{"message":"Cannot find function _marshal in object [object Object].","fileName":"/SuiteScripts/MR - Link Pre Appt Survey To Appt.js","lineNumber":50,"name":"TypeError","stack":"\tat /SuiteScripts/MR - Link Pre Appt Survey To Appt.js:50 (reduce)\n\tat INVOCATION_WRAPPER$sys:72\n\tat INVOCATION_WRAPPER$sys:25\n\tat INVOCATION_WRAPPER$sys:107\n\tat INVOCATION_WRAPPER$sys:4\n","rhinoException":"org.mozilla.javascript.EcmaError: TypeError: Cannot find function _marshal in object [object Object]. (/SuiteScripts/MR - Link Pre Appt Survey To Appt.js#50)"},"notifyOff":false,"userFacing":true}
Question:
I figured that it is the search object that is throwing error. And I can't use search.lookupFields & search.create altogether and managed to duck this by loading the record and getting the value. But I think I am missing something basic here and there must be a better way to do this. If someone knows what I missed, feel free to reply.
Thanks in advance!