Hi all I am looking for some help with my RESTlet....
# suitescript
l
Hi all I am looking for some help with my RESTlet. I created a restlet that uses task.create to export the results of a saved search to a folder in the file cabinet, and then email that file to a user based on the input. The issue I am running into is that it doesn't seem like task.create is async so the email to the user is sent before the file has been updated. Can someone help me out wih this?
var searchTask = task.create({
taskType: task.TaskType.SEARCH,
savedSearchId: '1587',
filePath: 'lead_storage/search_results.csv'
}).submit();
var taskStatus = task.checkStatus({
taskId: searchTask
});
if (taskStatus.status === task.TaskStatus.COMPLETE){ email the file... }
n
You might be able to move the email portion of the script to a later stage to ensure it finishes properly. Like if you are updating the files in map, send the file ID's to reduce, and have the reduce stage send the email
Ignore that, i had map/reduce in my head for some reason. I see now its a restlet
e
you could use the addInboundDependency to call another script to email the file when the task is complete
☝️ 1
l
Thanks!