Netsuite Suitescript可以修改文件柜中的文件吗?

发布于 2024-08-12 13:27:18 字数 143 浏览 9 评论 0原文

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

这可以做到吗?

谢谢

I have a large product list and need to generate a static file of it, and have that file be accessible in my website. Currently, I generate the list, and upload it to the file cabinet. I wish to automate this process. I would like to schedule a SuiteScript to run each night and generate this list and update a file in the file cabinet.

Can this be done?

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

东风软 2024-08-19 13:27:18

您可以使用 SuiteScript 自动执行此过程。您将使用 nlapiLoadFile 和 nlapiSubmitFile 调用来完成它。如果您的产品列表很大,您可能会遇到一些其他问题。您可能会达到治理限制,并且需要开发此脚本,以便它跟踪进度并适当地重新安排自身。 SuiteScript 搜索将仅返回前 1000 条记录。如果您要在此文件中包含超过 1000 个项目,您可能需要在项目记录上使用标记来跟踪哪些项目仍待导出。目前,使用 SuiteScript 加载或创建文件时,文件大小有 5MB 的限制。

You can automate this process with SuiteScript. You would use the nlapiLoadFile and nlapiSubmitFile calls to accomplish it. If you have a large product list you are likely to encounter a few other issues. You are likely to hit governance limits and will need to develop this script so that it tracks progress and reschedules itself appropriately. SuiteScript searches will only return the first 1000 records. If you have more than 1000 items to include in this file, you will likely need to use a flag on the item record to track which items remain for export. There is currently a 5MB limit on the file size when loading or creating files using SuiteScript.

半边脸i 2024-08-19 13:27:18

创建文件的 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);

Example SuiteScript to create a file:

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);
大海や 2024-08-19 13:27:18

是的,您可以使用计划脚本来完成此操作并根据您的意愿安排它们。
没有特殊的 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
}

Yes, you could do it using scheduled Scripts and schedule them as your wish.
There is no special API function to edit an existing file, you could take the details of the existing file and create a new file with the same details but changing the data field only and deleting the old file.

    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
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文