Home > Mobile >  2nd Function not executing - suitescript
2nd Function not executing - suitescript

Time:12-20

I have the below code. I want the function called execute2 to run after the function execute. When I put the script task inside the first function and don't include execute2 then it all runs fine and the second separate script runs. But when I run it in the below format it does not. What is preventing execute 2 from actually running here?

Thank you

/**
 * @NApiVersion 2.x
 * @NScriptType ScheduledScript
 * @NModuleScope SameAccount
 */
 
 define(['N/task'],
 
 /**
 * @param {record} record
 * @param {search} search
 */
 
 function(task) {
 
 var FILE_ID = 433961; 
 var SEARCH_ID = 1610;
 
 function execute(scriptContext) {
 
 var searchTask1 = task.create({
 taskType: task.TaskType.SEARCH
 
 });
 
 searchTask1.savedSearchId = SEARCH_ID;
 searchTask1.fileId = FILE_ID;
 
 var searchTaskId1 = searchTask1.submit();
 //
 //Next Task
 //
 FILE_ID = 433963;
     SEARCH_ID = 1606;
     var searchTask2 = task.create({
         taskType: task.TaskType.SEARCH
     });
 
     searchTask2.savedSearchId = SEARCH_ID;
     searchTask2.fileId = FILE_ID;
     var searchTaskId2 = searchTask2.submit();
 //
 //Next Task
 //
   FILE_ID = 434489;
     SEARCH_ID = 1637;
     var searchTask3 = task.create({
         taskType: task.TaskType.SEARCH
     });
 
     searchTask3.savedSearchId = SEARCH_ID;
     searchTask3.fileId = FILE_ID;
     var searchTaskId3 = searchTask3.submit();
 //
 // Next Task
 //
   FILE_ID = 434490;
     SEARCH_ID = 1606;
     var searchTask4 = task.create({
         taskType: task.TaskType.SEARCH
     });
 
     searchTask4.savedSearchId = SEARCH_ID;
     searchTask4.fileId = FILE_ID;
     var searchTaskId4 = searchTask4.submit();
 
 }
 
 function execute2(scriptContext){
 
      var scriptTask = task.create({
       taskType: task.TaskType.SCHEDULED_SCRIPT,
       scriptId: "customscript_email_sender",
       deploymentId: "customdeploy_email_sender_d"
     });
 
     var scriptTaskId = scriptTask.submit();
 
 }
 
 return {
 
   
   execute: execute,
   execute2: execute2,
 
 };
 
 });

CodePudding user response:

Building on log.debug output from scheduled script

  • Related