Map/ReduceスクリプトのgetInputDataメソッドで検索をロードしました。 とし、MapメソッドとgetInputDataメソッドで検索を実行しようとしました。「N/search」モジュールを使用して作成された検索は、Map/Reduce Scriptで実行できますか?
ユーザイベント、スケジュールスクリプト、クライアントスクリプト、Suitletスクリプトのような通常のスクリプトで、すべて我々が検索を作成し、検索使用して、実行()またはrunPaged()メソッドを実行することができます。
私の質問は、getInputDataメソッドまたはMap/Reduce Script?のrun()メソッドまたはrunPaged()メソッドを使用して検索を実行できることです。
If検索結果列を次の段階、つまり[マップ]または[縮小]に渡す方法を意味します。
マイコード:事前に
define(['N/error', 'N/record', 'N/search', 'N/log', 'N/task', 'N/runtime', 'N/email'],
/**
* @param {email} email
* @param {record} record
* @param {runtime} runtime
* @param {search} search
* @param {task} task
* @param {transaction} transaction
*/
/* this script is used to create the search on the invoice and store the obtained search results on the object and trying to create the another search based on the values on the object */
function(error, record, search, log, task, runtime, email) {
function getInputData() {
log.debug("Get Input", "Initiated");
//Invoice Search
var invoiceSearch = search.load({
id: 'customsearch_invoice_calc'
});
log.debug("invoiceSearch:", invoiceSearch);
//Creating the Object for Storing Search Results
var invoiceDetails = {};
var invoiceId = "Id";
var invoiceLineId = "invoiceLineId";
//Running the Search
var myPagedData = invoiceSearch.runPaged({
"pageSize": 1000
});
log.debug('myPagedData:', myPagedData);
myPagedData.pageRanges.forEach(function(pageRange) {
// Fetch the results on the current page
var myPage = myPagedData.fetch({
index: pageRange.index
});
log.debug('myPage:', myPage);
// Iterate over the list of results on the current page
myPage.data.forEach(function(result) {
// Process the individual result
invoiceDetails[invoiceId] = result.getValue({
name: 'internalid'
});
invoiceDetails[invoiceLineId] = result.getValue({
name: 'line'
});
});
})
log.debug("invoiceDetails:", invoiceDetails);
return invoiceSearch;
}
function map(context) {
log.debug("Map", "Initiated");
var searchResult = JSON.parse(context.value);
var invoiceId = searchResult.id;
var lineId = searchResult.values.line.value;
log.debug("invoiceId:", invoiceId);
log.debug("lineId:", lineId);
comCalulation(invoiceId, invoiceId);
context.write(invoiceId);
}
function commissionCalc(invoiceId, lineId) {
log.debug("Entered:", "Commission Calc Function");
log.debug("invoiceId - Inside Commission Calc:", invoiceId);
}
function reduce(context) {
log.debug("Reduce", "Initiated");
}
function summarize(summary) {
log.debug("summarize", "Initiated");
}
感謝。