- CALL : (+1) 407-273-1001
- Main Office : (+1) 407-273-1001
- NetSuite NetSuite Customization
- May 04
- 3 mins read
NetSuite Document Management: Automated File Sharing Between Partners

NetSuite Document Management
NetSuite document management is a never ending process for some businesses. In previous posts, we have shown you how to create a CSV file from a NetSuite saved search. Now we would like to add another step on to that process. What if you would like to send that CSV file to a partner on a regular basis, let’s say daily?
In our example, Sporting Good Inc., needed to create CSV files populated with customer information. They were able to accomplish this by using a NetSuite saved search and a custom SuiteScript.
Here is the script we created for Sporting Goods Inc.
function createFile(){
try{
var searchResults = nlapiSearchRecord(null, 'customsearch_cust_for_mega_ pub');
var csvBody = '';
if (searchResults == null || searchResults.length < 1) return;
for (var i=0; i<searchResults.length; i++){
csvBody += searchResults[i].getValue(' entityid') + ',';
csvBody += searchResults[i].getValue(' email') + ',';
csvBody += searchResults[i].getValue(' phone') + '\n';
updateCustomer(searchResults[ i]);
}
var file = nlapiCreateFile(' MegaPublishing_Customers.csv', 'CSV', csvBody);
file.setFolder('1067');
nlapiSubmitFile(file);
}catch(e){
nlapiLogExecution('Error', 'createFile', 'Error while creating file - ' + e.message);
}
}
function updateCustomer(customerId){
var fields = ['custentity_sent_to_mega_ publishing'];
var values = ['T'];
nlapiSubmitField('customer', customerId, fields, values, false);
}
This script gets the job done. We now have a CSV file filled with information from NetSuite. Now Sporting Good Inc., needs to send this CSV to their trading partner, Mega Publishing, every day. To do this, they’ll need a bit more code and the help of NetSuite.
First they need to decide how they want to send the CSV: by email or by web server. This is the code they’ll need to add to their Suitecript if they wish to send the CSV via email.
var fileId = nlapiSubmitFile(file);//creates the file into the file cabinet - optional
//This portion will email the file
var EMPLOYEE_ID = '9999'; //NetSuite requires an actual id of an employee
var email = 'partner@megapublishing.com';
var subject = 'Customer Records';
var body = 'Attachment is included';
nlapiSendEmail(EMPLOYEE_ID, email, subject, body, null, null, null, file);
And this is what they would add if they wished to send the CSV’s via web server.
var fileId = nlapiSubmitFile(file);//creates the file into the file cabinet - optional
//This portion will post the file to a webserver
var url = 'http://www.megapublishing.com/processcustomers';
var postContent = csvBody;
var headers = [];
headers['Content-Type'] = 'text/xml; charset=UTF-8';
nlapiRequestURL(url, postContent, headers);
For our example, let’s say they wish to send the example via email. So let’s place the new code into the script we made earlier.
function createFile(){
try{
var searchResults = nlapiSearchRecord(null, 'customsearch_cust_for_mega_pub');
var csvBody = '';
if (searchResults == null || searchResults.length < 1) return;
for (var i=0; ii<searchResults.length; i++){
csvBody += searchResults[i].getValue('entityid') + ',';
csvBody += searchResults[i].getValue('email') + ',';
csvBody += searchResults[i].getValue('phone') + '\n';
updateCustomer(searchResults[i]);
}
var file = nlapiCreateFile('MegaPublishing_Customers.csv', 'CSV', csvBody);
file.setFolder('1067');
var fileId = nlapiSubmitFile(file);//creates the file into the file cabinet - optional
var EMPLOYEE_ID = '9999'; //NetSuite requires an actual id of an employee
var email = 'partner@megapublishing.com';
var subject = 'Customer Records';
var body = 'Attachment is included';
nlapiSendEmail(EMPLOYEE_ID, email, subject, body, null, null, null, file);
}catch(e){
nlapiLogExecution('Error', 'createFile', 'Error while creating file - ' + e.message);
}
}
function updateCustomer(customerId){
var fields = ['custentity_sent_to_mega_publishing'];
var values = ['T'];
nlapiSubmitField('customer', customerId, fields, values, false);
}
Alright, now we have our script set up! NetSuite will take data from a saved search, turn it into a CSV file and then email the information to Sporting Goods Inc.’s partner, Mega Publishing.
Now we must configure NetSuite to send the CSV on a daily basis. To do this, first we go to Customization -> Scripting -> Scripts and find our Script. Then click Edit, and in the deployment tab select how often to deploy the script. We select daily for Sporting Goods Inc.’s needs.
There you have it! We have our information being sent to our partner on a regular basis, automatically, all thanks to NetSuite and a little developer know-how. If we lost you somewhere or you have any questions about automation or NetSuite document management in general, please let us know in the comments below! As always, thank you for reading.
Jeremy McCourt is an content producer in the enterprise software industry that focuses on NetSuite and related cloud-based software solutions.
Related Posts

NetSuite Document Management Explained: The 2023 Guide
Proper document management is an important part of managing your business as it can easily affect everything from compliance to productivity. Growing companies must find a way to efficiently manage and streamline their document management…
- Mar 06
- 4 mins read

NetSuite Consolidated Invoicing: The 2023 Guide For NetSuite Users
Contact us! As businesses grow, managing invoicing can become more complex, especially if there are multiple subsidiaries or transactions involved. To help streamline invoicing processes and ensure accuracy, NetSuite users look for tools to consolidate…
- Feb 15
- 4 mins read
Subscribe to the eMerge Technologies Mailing List
eMerge Technologies Services
Recent Posts
- NetSuite Document Management Explained: The 2023 Guide
- NetSuite Consolidated Invoicing: The 2023 Guide For NetSuite Users
- Case Study: Retail Company Explores Financial Goals
- Financial Planning and Analysis Overview: The Foundation for Successful CFOs
- What is Dell Boomi? The 2023 Guide to a Leading IPaas