Forums › Cached › CSV Import
This topic contains 14 replies, has 0 voices, and was last updated by khultquist 9 years, 7 months ago.
-
AuthorPosts
-
October 10, 2014 at 12:47 pm #24146
adangHi Everyone,
I have written a scheduled suitescript code in which imports a csv and maps the variables at a certain time, given that the file already exists in the file cabinet and the ID is known.
However, I still have not been able to find a way to upload a file to the file cabinet automatically. I'd like to be able to push a csv file from a local drive or ( server drive \serverdatabasepdmbook1.xls) to the file cabinet when changes are made to the file or new version is available ( Maybe use MSMQ to trigger a code to push the data from my PC to file cabinet?) . Would this be possible?
I do not have that much of experience in JS or API, but very keen to learn.
This is the code I have for scheduled import script:
Code:
function scheduledimporting(type){var csvMap = '15';
var csvFile = nlapiLoadFile("5828"); //csv file id from filecabinet
//************************************************** *************************************
// originally thought of the below code to use and fetch data from a url but did not work
// var urlrequest=nLapiRequestURL('https://………..',null,a);
// var body=response.getBody(); //get the body of the message
//************************************************** ***********************************
var csvImport = nlapiCreateCSVImport();//creating a new csv import
csvImport.setMapping(csvMap);//setting import map
csvImport.setPrimaryFile(body.getValue());//file to be imported
csvImport.setOption("jobName", "Test1111");
var csvSubmitId = nlapiSubmitCSVImport(csvImport);//submitting the CSVAny help is appreciated.
Thanks,
This is a cached copy. Click here to see the original post. -
October 14, 2014 at 12:46 pm #24147
adangBUMP .
-
October 30, 2014 at 6:32 pm #24148
srodriguezWhat error were you getting when trying to retrieve the file from a server location? I do see you have the API incorrectly formatted – should be nlapiRequestURL instead of nLapiRequestURL. That would definitely throw an error.
-
January 29, 2015 at 2:28 pm #24149
adurangalvisI am also very interested in this, please if someone can help with this.
-
February 9, 2015 at 5:13 pm #24150
teddycaguioaIn order to upload a local file to the File Cabinet, you need to write a desktop program (for example .NET Forms). You then use web services to upload the files to the file cabinet.
-
April 7, 2015 at 6:25 am #24151
jwenzerAnother option that I just got to work is to use the new Email Capture plug in. I am having our outside system that employees punch time email "Netsuite" a report every night, and now I can save the csv file to the file cabinet automatically! It works great.
Does anybody know if there is a way after performing the nlapiSubmitCSVImport to have the system automatically email the response file so a user does not have to login in the morning to check the status of the import?
-
April 7, 2015 at 6:48 am #24152
khultquistjwenzer – was there any trick to getting the Email Capture plugin installed? I can't find it in suitebundle search.
-
April 7, 2015 at 7:07 am #24153
jwenzerI had the same issue. Turns out, if you are on 2015.1, you already have it! Go to Customization, Plug-ins, Plug-in Implementation, and you can create a new one of type Email Capture. You'll need to have your script file uploaded already that has the function to process the email. After creation, you get the Netsuite assigned Email Address to use
-
April 7, 2015 at 7:10 am #24154
khultquistThanks for the help!
-
April 7, 2015 at 9:21 am #24155
khultquistI've run some successful tests with Email Capture. I have to say that I like the feature, but it seems incomplete, like it's still in beta:Very difficult to follow the implement instructions, because as of 2015.1 the plug-in is already installed in account (instructions tell you to install a bundle)
Why is this a "plug-in" anyways? Shouldn't it just be part of suitecloud?
No option to "Run as Administrator". You can choose the role "System Administrator", but that is not the same.
To discover the incoming email address, you have to "implement", then "manage".
To run the implementation, you have to check a box on the "manage" page, and it's not clear what this checkbox does. Apparantly it "enables" the plug-in implementation, but it would make more sense and be more consistent if this was a "deployment"
The implementation should have the option to run other script functions, similar to how other suitescripts work. I cannot choose my function name, it must be "process(email)" -
April 8, 2015 at 10:00 am #24156
wwintersI thought that the Email Capture feature might be a great way to import sales orders from an external system, like Ariba that sends orders via email as an XML attachment, but it seems that the Suitescript XML APIs are not implemented in the plug-in…
When I loop thru the attachments and find the one of type XMLDOC, and then getValue() of the attachment for the raw XML and use nlapiSelectValue, I get the following error:
Can't find method $Proxy105.nlapiSelectValue(string,string)
Any luck using XML API's with the Email Capture plug-in?
Thanks!
Wes
-
April 8, 2015 at 10:18 am #24157
khultquistwwinters – In my account, I used Email Capture to simply move attachments to a designated File Cabinet folder. Once the files are there, I have a scheduled script that looks for files in that folder and imports them
If your scripts work in regular suitescript, you could do something similar.
-
April 8, 2015 at 10:23 am #24158
wwintersThanks for the quick reply!
I'll save the file and process with a scheduled script then.
Best,
Wes
-
April 8, 2015 at 12:17 pm #24159
wwintersOK, I have the file saved into a new folder I just created in the File Cabinet. How do I look for/loop through files in that folder in the scheduled script? I don't have the file ID.
Thanks!
Wes
-
April 8, 2015 at 12:33 pm #24160
khultquistHere's a snippet of my script that searches a folder, then moves the file to a completed folder
Code:
var in_folder = 260191; // folder name = "ASN Incoming"
var out_folder = 260192; // folder name = "ASN Completed"// *** Search Folder ***
var filters = [];
filters.push(new nlobjSearchFilter('folder', null, 'is', in_folder));
var file_results = nlapiSearchRecord('file', null, filters);// *** Loop Thru Results ***
for (var i in file_results) {
var file_result = file_results[i];
var fileId = file_result.getId();
var file = nlapiLoadFile(fileId);
var fileName = file.getName();
var fileType = file.getType();
var fileSize = file.getSize();
var fileContents = file.getValue();
…
}…
// *** Move File to Completed Folder ***
if (!found_error) {
var copiedFile = nlapiCreateFile(fileName, fileType, fileContents);
copiedFile.setFolder(out_folder);
nlapiSubmitFile(copiedFile);
nlapiDeleteFile(fileId);
} -
AuthorPosts
You must be logged in to reply to this topic.