Marc
11/29/2023, 6:15 PMMarc
11/29/2023, 6:15 PM* @NApiVersion 2.1
* @NScriptType ScheduledScript
* @NModuleScope SameAccount
*/
define(['N/task', 'N/search'], function (task, search) {
/**
* Definition of the Scheduled script trigger point.
*
* @governance
*
* @param {Object} scriptContext
* @param {string} scriptContext.type - The context in which the script is executed. It is one of the values from the scriptContext.InvocationType enum.
*/
function execute(scriptContext) {
const WEB_QUERY_FOLDER = 32273;
//load files from File Cabinet
var folderSearchObj = search.create({
type: 'folder',
filters: [['internalidnumber', 'equalto', WEB_QUERY_FOLDER]],
columns: [
search.createColumn({
name: 'name',
sort: search.Sort.ASC,
label: 'Name'
}),
search.createColumn({
name: 'name',
join: 'file',
label: 'Name'
}),
search.createColumn({
name: 'internalid',
join: 'file',
label: 'Id'
})
]
});
var resultsFiles = folderSearchObj.run().getRange({
start: 0,
end: 98
});
log.debug('resultsFiles.length', resultsFiles.length);
var searchIds = [391];
let myTask = task.create({
taskType: task.TaskType.SEARCH
});
myTask.savedSearchId = searchIds[0];
/*myTask.fileId = resultsFiles[i].getValue({
name: 'internalid',
join: 'file'
});*/
myTask.fileId = 208364;
log.debug('file id ', myTask.fileId);
/*myTask.filePath = 'Web Query/' + savedSearchName + '.csv';*/
let myTaskId = myTask.submit();//100 units
log.debug('myTask.savedSearchId ', myTask.savedSearchId);
log.debug('myTaskId', myTaskId);
// return false;
// }
}
return {
execute: execute
};
});
battk
11/29/2023, 6:32 PMMarc
11/29/2023, 6:34 PMbattk
11/29/2023, 7:21 PMbattk
11/29/2023, 7:21 PMbattk
11/29/2023, 7:22 PMMarc
11/29/2023, 7:56 PMbattk
11/29/2023, 8:09 PMbattk
11/29/2023, 8:09 PMMarc
11/29/2023, 8:14 PMbattk
11/29/2023, 8:17 PMMarc
11/29/2023, 8:31 PMbattk
11/29/2023, 8:32 PMbattk
11/29/2023, 8:33 PMMarc
11/29/2023, 8:35 PMbattk
11/29/2023, 8:39 PMbattk
11/29/2023, 8:40 PMMarc
11/29/2023, 8:46 PMbattk
11/29/2023, 8:51 PMbattk
11/29/2023, 8:51 PMbattk
11/29/2023, 8:51 PMMarc
11/29/2023, 8:52 PMMarc
11/29/2023, 8:52 PM/**
@NApiVersion 2.1
@NScriptType ScheduledScript
*/
define(['N/search', 'N/file', 'N/log', 'N/runtime', 'N/task'], function (search, file, log, runtime, task) {
function execute(scriptContext) {
try {
var savedSearchId = runtime.getCurrentScript().getParameter('custscript_saved_search_id');
var savedSearchName = runtime.getCurrentScript().getParameter('custscript_saved_search_name');
let myTask = task.create({
taskType: task.TaskType.SEARCH
});
log.debug('savedsearchid', savedSearchId);
myTask.savedSearchId = savedSearchId;
myTask.filePath = 'Web Query/' + savedSearchName + '.csv';
let myTaskId = myTask.submit();//100 units
} catch (e) {
log.error("Scheduled Script Error", e.toString());
}
}
return {
execute: execute
};
});
Marc
11/29/2023, 8:52 PMbattk
11/29/2023, 8:54 PMbattk
11/29/2023, 8:54 PMbattk
11/29/2023, 8:55 PMbattk
11/29/2023, 8:55 PMMarc
11/29/2023, 9:06 PMbattk
11/29/2023, 9:10 PM