Hello! I am working on a scheduled script that tak...
# suitescript
k
Hello! I am working on a scheduled script that takes a batch of csv files from the file cabinet and creates a task to run csv import in the system. Right now, all csv files are going through one queue, is it possible to create tasks in the script so that multiple csv import queues can be triggered?
m
You can set the
queueId
property on the CSV import task before you
submit()
it. https://system.na0.netsuite.com/app/help/helpcenter.nl?fid=section_454650817870.html
You'll have to manage balancing across the queues in your code.
k
Thank you! That is really helpful, I will try this out.
Just one follow up question, when you say balancing, do you mean which file goes in which queue?
m
Yeah. If you're processing your files in a loop of some kind you can do it with something like this:
Copy code
fileIds.forEach(function(fileId, index) {
    var maxQueueCount = 5;
    
    // Create your import task here
    
    importTask.queueId = (index % maxQueueCount) + 1; // Since maxQueueCount is 5, this will result in a value of 1 to 5 and then repeat for as many files that you have.
    importTask.submit();
});
k
awesome, thank you so much! I appreciate your help!!