我想知道是否可以使用nlapiLoadFile()从服务器(公司或本地驱动器内的服务器)的外部驱动器调用文件,而不是从文件柜中调用文件。 (该文件必须手动上传)?所以我可以使用它来使用nlapiCreateCSVImport()来导入文件。Netsuite文件柜
谢谢。
我想知道是否可以使用nlapiLoadFile()从服务器(公司或本地驱动器内的服务器)的外部驱动器调用文件,而不是从文件柜中调用文件。 (该文件必须手动上传)?所以我可以使用它来使用nlapiCreateCSVImport()来导入文件。Netsuite文件柜
谢谢。
不可以。您可以使用必须可从外部服务器访问的nlapiRequestURL。
@pipechang这是我到目前为止,我不能完全理解它,当你说我需要将消息正文转换为JSON 如果我把文件作为XML拉入,那么我是否仍然需要将其转换为JSON当我读取身体?如果不是,那么我如何能够稍后将它转换为CSV?/
感谢您的帮助。
function scheduledimporting(type){
var csvMap = '15'; //saved CSV import id
//var csvFile = nlapiLoadFile("5828"); //csv file id from filecabinet
var urlrequest=nLapiRequestURL('https://...........',null,a);
var body=response.getBody(); //get the body of the message
var csvImport = nlapiCreateCSVImport();//creating a new csv import
/***
If the file that I'm pulling in is a CSV, would i get the body as CSV?
DO I still need to go through Prsing the body and transform it to JSON Object
If I do, how would I transfer it back to CSV ?
***/
csvImport.setMapping(csvMap);//setting import map
csvImport.setPrimaryFile(body.getValue());//file to be imported
csvImport.setOption("jobName", "Test1111");//setting job status' job name
var csvSubmitId = nlapiSubmitCSVImport(csvImport);//submitting the CSV
}
您可以在Netsuite的脚本调试器中运行您的功能内容。 https://system.netsuite.com/app/common/scripting/scriptdebugger.nl – 2014-10-07 09:22:10
我该如何使用它从保险库导入csv文件。它会是像nlapiREquestURL(....// server12/forler12321/1.csv)。那我是否需要回复?感谢您的帮助 – 2014-09-30 18:47:51
@Jamesguilford,您将得到一个响应对象,您必须从中提取body属性,它是csv本身(请参阅帮助文件中的nlresponseobj)。然后你需要找到一个解析器来将响应主体字符串转换成JSON对象 - 在github上搜索。从那里它是纯粹的JS。另外现在我注意到你的驱动器是本地的,你必须使这个文件可以在网络上使用,因为NetSuite服务器不能看到你的本地网络..把它放在一个ftp服务器或其他东西。 – pipechang 2014-10-01 21:14:58
有趣...然后我怎么会将JSON转换回CSV导入?@pipechang – 2014-10-03 17:26:25