我有一个大的产品列表,需要生成一个静态文件,并有该文件是在我的网站访问。目前,我生成列表,并将其上传到文件柜。我想这个过程自动化。我想安排一个SuiteScript每天晚上运行,并生成该列表,并更新文件柜的文件。

可以这样做?

感谢

有帮助吗?

解决方案

可以用自动化SuiteScript此过程。你会使用nlapiLoadFile和nlapiSubmitFile调用来完成它。如果你有一个大的产品列表,你很可能会遇到一些其他问题。你可能会击中治理限制和需要,使其轨道上取得进展,并适当地重新安排自己开发这个脚本。 SuiteScript搜索将只返回第1000条记录。如果你有超过1000个项目在该文件中包含,你可能会需要使用标志的项目记录来跟踪项目仍然是出口。装载或使用SuiteScript创建文件时目前的文件大小5MB限制。

其他提示

实施例SuiteScript创建一个文件:

var data = 'Your,CSV,File,Here';
var folderId = 519; // Your File Cabinet folder ID here

// Create the file and add it to the folder
var f = nlapiCreateFile('products.csv', 'CSV', data);
f.setFolder(folderId);
var id = nlapiSubmitFile(f);

// If you want to attach the file to a record, you can do something like this:
nlapiAttachRecord('file', id, 'customrecord_x', recordId);

是的,你可以使用计划脚本做到这一点,他们安排你的愿望。 有没有特殊的API函数编辑现有的文件,你可以采取的现有文件的详细信息,并创建一个具有相同的细节一个新的文件,但只改变数据字段,删除旧文件。

    var start = function(request, response)
{
    var fileId = "107524";//get the existing file id
    var file = nlapiLoadFile(fileId);
    var data = file.getValue();
    var name = file.getName();
    var folderId = file.getFolder();
    var fileType = file.getType();
    nlapiDeleteFile(fileId);//delete the older file

    data += "this is the appended data";//change the data
    var newFile = nlapiCreateFile(name, fileType, data);//create a new file with the same details
    newFile.setFolder(folderId);
    nlapiSubmitFile(newFile);//submit it
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top