Are N/query Query objects not okay to return from ...
# suitescript
a
Are N/query Query objects not okay to return from a MapReduce : getInputData function? The documentation says it expects this as one of the returned types. But when I try to do it, it fails in the MapReduce status details but does not catch any errors from the following code:
Copy code
function getTransactions(){
		try{
			const curScript = runtime.getCurrentScript();
			const datasetId = curScript.getParameter({name: "custscript_fbsg_distautobill_dataset"});
			
			const myQuery = query.load({id: datasetId});
			const condYesterday = myQuery.createCondition({fieldId: "createddate", operator: query.Operator.ON, values: "today"});//TODO: Change to yesterday once done testing.
			myQuery.condition = myQuery.and(myQuery.condition, condYesterday);
			
			log.debug("getTransactions condition", myQuery.condition);
			return myQuery;
		}catch(err){
			log.debug("getTransactions error", err);
		}
	}
What's going on?
d
It should be ok, but why function name is getTransactions not getInputData?
s
Also, if there are errors, you should work with them in the
summarize
stage. If you're not doing that then it's possible you're just not seeing the errors that are happening.
2
a
@Dmitry Masanov I was specifying what the getInputData entry point does: return { getInputData: getTransactions, map: autoBillOrCredit, summarize: doSummary };
👍 1
Thanks, the summary caught errors that even the try/catch didn't, probabl because actually executing the query happens between the getInputData and the map function running. I found out what was wrong 🙂 bad search query terms.
👍 1