Is trhere a way to create multiple schedulers using Javascript?

Hi Experts,

currently I'm using JS to insert a scheduler record to process some of the IM tickets. but currently this scheduler is taking more than 5 minutes if there is more than 100 tickets. so, is there a way to create multiple schedulers of the same type if there are large number of IM tickets are submitted for Mass Cancel?

any help would be appreciated!

thanks.

  • You can have multiple schedulers but try to have slight variation in the execute condition!

    AB!

  • Execute condition of what? could you please be specifc

  • It may also be worth investigating wny the current script is executing so slowly. You've indicated "more than 100" but even if it's a couple thousand, not sure why it would take that long. 

    Can you explain what your script is doing and post it for review?


  • //this Script is for IM Mass Cancel. this script will be called from the Scheduler

    function imMassCancel(imParent,imRes,imSubRes,imDesc,imOperator,imGlist)
    {    
        var tempList=imGlist.split(',');
        
        var imList = new Array();
        
        for (var j=0;j<tempList.length;j )
        {
            imList[j]=tempList[j];
        }
            
        var opRec = new SCFile("operator")            //to check if the operator belongs to the FLOG or IM Assignment group
        var opRes = opRec.doSelect("contact.name=\"" imOperator "\"");
        var asgnarray=new Array();    
        asgnarray=opRec.assignment_groups        //asgnarray=vars.$lo_pm_im_assignments
        
        var resarray= new Array();    
        var len = 0;        
        var len = system.functions.lng(imList);        //print("length" len);
            
        var imRec =  new SCFile("probsummary")
        
        for (var i=0; i <len; i )    
        {
            //system.functions.rtecall("log", undefined, "Sunil-->i=" i " imList is " imList[i]);     
             var rc1 = imRec.doSelect("number=\"" imList[i] "\" and (problem.status=\"Closed\" or problem.status=\"Cancelled\")")
              if(rc1 == RC_SUCCESS)
               {
                //print(imList[i] " is not updated. Reason: The ticket already in " imRec.problem_status " status.");
                system.functions.rtecall("log", undefined, imList[i] " is not updated. Reason: The ticket already in " imRec.problem_status " status.");
                continue;
            }
              var rc = imRec.doSelect("number=\"" imList[i] "\" and (problem.status~=\"Closed\"and problem.status~=\"Cancelled\")")          
                      
          
            var x= system.functions.index(imRec.assignment, asgnarray);        //to check if the operator belongs to IM Assignment group
            var y=system.functions.index(imRec.open_group, asgnarray);        //to check if the operator belongs to the FLOG
            
            if(x>0 || y>0)
            {                   
               if(rc == RC_SUCCESS)
               {
                      imRec.problem_status="Cancelled"                
                    imRec.resolution_code=imRes;        //imRec.resolution_code=system.vars.$tr_resolution;                    
                    imRec.abend_code=imSubRes;            //imRec.abend_code=system.vars.$tr_subresolution;
                    imRec.tr_canceldesc=[];
                    imRec.resolution=[];                
                    imRec.tr_canceldesc[0]=imDesc;        //imRec.tr_canceldesc[0]=system.vars.$tr_masscancel_reason // "\n" imRec.tr_canceldesc[0];                    
                    imRec.resolution[0]=imDesc;            //imRec.resolution[0]=system.vars.$tr_masscancel_reason;                                
            
                    //to insert an activity notes
                    imRec.update_action[0]="Cancelled by " system.functions.operator() " (" system.functions.str(system.functions.tod()) ")" "\n" imRec.resolution[0] "\n" imRec.update_action[0];
                
                       var rc2 = imRec.doAction("update");
                       
                    if(rc2==RC_SUCCESS)
                    {                    
                        //below code is to insert an activity --> Mass Cancelled
                        var imactivity=new SCFile("activity");
                        imactivity.number=imList[i];                
                        var today = new Date();
                        imactivity.datestamp=today;
                        imactivity.type="Mass Cancelled";
                        imactivity.operator=system.vars.$lo_user_name;
                        if (imParent!="null")
                        {
                            imactivity.description[0]=imParent;
                        } else {
                                    imactivity.description[0]=null
                                }
                        
                        var now = new Date(system.functions.tod());
                        var future = new Date(2200,1,1);
                        var delta = future - now - (30 * 86400000);
                        var days = String(parseInt(delta/86400000));
                        var hours =String(parseInt((delta - (days*86400000))/3600000));
                        var minutes =String(parseInt((delta - (days*86400000) - (hours*3600000))/60000));
                        var seconds =String(parseInt((delta - (days*86400000) - (hours*3600000) - (minutes*60000) )/1000));
                        var negdatestamp = new XMLDate( "P" days "DT" hours "H" minutes "M" seconds "S");
                        negdatestamp=negdatestamp.getDatum();
                        imactivity.negdatestamp=negdatestamp
                        
                        imactivity.doInsert();
                        
                    } else {                            
                                //print("Could not update the ticket number " imList[i] ". " imRec.getMessages());    
                                system.functions.rtecall("log", undefined, "Could not update the ticket number " imList[i] ". " imRec.getMessages());
                            }
                }
            }else     {
                        //print("Could not update the ticket number " imList[i] ". " "Reason: You do not belong to " imRec.assignment " group");
                        //print("Could not update the ticket " imList[i] ". " "Reason: You are not a member of Assignment Group or Front Line Owner Group.");
                        system.functions.rtecall("log", undefined, "Could not update the ticket " imList[i] ". " "Reason: You are not a member of Assignment Group or Front Line Owner Group.");
                    }

          } // main for loop ends here.

         system.vars.$G_incident_ids = null;
        
    }