How to return the file from the suitelet to anothe...
# suitescript
n
How to return the file from the suitelet to another script like map-reduce? response.writeFile()?
m
I can't think of way you could pass it directly. You can create a script parameter on the map-reduce that holds the file id and then use
N/task
to start the map-reduce and set the script parameter to the file id.
You could also just have a directory that holds files waiting to be processed and and processed directory they are stored in after processing.
n
Can't it be similar to how we download a file from the server using https.get()?
m
I can't think of a way to accomplish that. I would say that most likely you are going to have to store it in the filesystem to be able to pass it.
n
Got it. Thanks
b
skip the suitelet and generate the file in the map/reduce itself
n
Suitelet is already created and generating the PDF from the record.
I need MR to generate the PDF and send it via email.
I figured out a workaround. Returned the PDF body as string from Suitelet and created the PDF file in MR.
m
Just out of curiosity, when you say your passing the string to the M/R script how are you passing it?
n
response.write() from suitelet.
m
Do you mean you are calling the Suitelet from the M/R script?
I think I misunderstood and thought the user was doing something in the Suitelet and you were trying to pass results into an M/R script.
b
he made the suitelet external (a data risk), and is making an https request from the map/reduce
m
Yeah I didn't make that connection till much later. He technically doesn't have to make it external I don't think unless it's not in the same environment.
b
the map/reduce does not have the required cookie to access internal urls
m
Oh that's a restriction I wasn't aware of.
Yeah the solution would be to just move the logic to the M/R script. Or move it to a shared module and that way the suitelet and M/R could share the logic.
n
@Marvin yes, @battk is correct. I tried to access it with internal URL only to realize that MR doesn't have "user" context but system one.