I am trying to query a SUITEQL task. I can see the...
# suitescript
n
I am trying to query a SUITEQL task. I can see the task id in my script execution logs. When I run a task.checkStatus using an id from the logs it always returns an error saying it's not a valid id. Logically, you'd surmise, it's not a valid ID, user error etc but I'm copy/pasting the id straight from the logs. This is the code I'm running:
Copy code
require(['N/task'], (task) => {
const status = task.checkStatus({
    taskId: 'SUITEQL_really_long_string_i_wont_include_here'
});
const a = 1; // add breakpoint here.
})
Nothing ground breaking, so anyone any idea why this is happening? Also, I have used id's from this morning, so pretty confident they haven't expired!
s
I think SuiteQL queries are not associated with background task IDs
m
It should work for SUITE_QL types. The code below works for me in a user event script. It did NOT work from the NS Script Debugger. It was telling me that the task type was invalid.
Copy code
var taskId = task.create({
    taskType: task.TaskType.SUITE_QL,
    query: 'select top 1 id from customer',
    filePath: '/SuiteScripts/MDR/test.csv'
}).submit();

log.debug({ title: 'taskId', details: taskId });

var status = task.checkStatus({
    taskId: taskId
});

log.debug({ title: 'status', details: status });
n
Thank you for replying @Mike Robbins It does seem that it is not possible to retrieve the details in the debugger. The seems to be that it seems to happen intermittently in a RESTlet too 😞 But at least now I can stop chasing my tail in the debugger.