Millet Antoine
Millet Antoine

Reputation: 425

How to create a downloadable file button on form

I want to create a button on a purchase order form to download in one file all the different item lines in a csv file.

I created a suitlet file and a user event script. The user event script create a button that redirect on the url of my suitlet script to execute a function. For now a create a file csv in a folder, but I don't know how redirect on the file url or to directly download the file

Upvotes: 0

Views: 1314

Answers (1)

Martha
Martha

Reputation: 764

Load the file, get the url property (it's not a link to the NS record/file it's a download link), open the url.

In SuiteScript 1.0

var file = nlapiLoadFile('file_id');
var url = "https://system.netsuite.com" + file.getURL();
window.open(url, '_blank');

In SuiteScript 2.0

var filePath = file.load({
  id: 'Images/Desert.jpg'
});
var url = file.url;
window.open(url, '_blank');

Upvotes: 1

Related Questions