Hi all, I want to export a file from a saved sear...
# suitescript
h
Hi all, I want to export a file from a saved search (using task.create with "SavedSearch" taskType) but this saved search varies depending on the customer. Our default saved search doesn't have the customerId filter. There are thousands of customer so it wouldn't be efficient to create a saved search for each of them in NS. What would be the best way to tackle that? TIA
a
load the search in suitescript before you run it and add the filter there? I'm not sure what's triggering the task so where can you can you get the customerId from?
💯 1
thanks 1
n
You can push filters to a saved search. So the script would just load the default then use
searchObj.filters.push(//customer filter here)
👍 1
w
If you have to do it async with the task-module. You could either A) save a temporary search where you add the filter to the base search and then add an inbound dependency to delete the search afterwards. B) rewrite it as a suiteql and use params
👍 1
h
@Anthony OConnor i have the customerId passing from getInputData stage, the task.create happens in the Map stage. Let me try your approach and report back
a
yeah that should be fine... you have an array of customerIds passed in via script param? or something search you're doing in the GIS?
h
@Anthony OConnor i have an array of customerIds passed in from a saved search in GetInputData phase of a Map/Reduce script
Looks like it's working, thanks everyone 🙂
👍 1
d
quick question. are you still using the task.create method in the Map stage? Or did you switch to running it directly (i.e. using
search.load.run()
)?
h
@David B I actually use search.create to create a new saved search then searchObj.save() to get the search internal id. Then i use the search internal id for task.create to export the search and save in File Cabinet
d
are you reusing the searches on subsequent runs of the map/reduce script? or just deleting them when the saved search task resolves the inbound dependency?
h
I am going to delete it after the saved search task resolves
👌 2