Reputation: 31
I'm trying to create a file via a restlet with code such as:
/**
*@NApiVersion 2.x
*@NScriptType Restlet
*/
define(['N/file'], function (file) {
var fileRequest = {
name: 'test' + '.txt',
fileType: file.Type.PLAINTEXT,
contents: 'test',
description: 'f',
folder: 165
};
try {
var resultingFile = file.create(fileRequest);
}
catch (ex) {
debugger;
}
var fileId = resultingFile.save();
});
When i run this i receive an error at the file.create with the following message: 'Unexpected Error'.
Upvotes: 0
Views: 3102
Reputation: 3287
With SuiteScript 2.0, you need to have a JSDoc comment block at the top of the file.
It looks like you're trying to create a custom module so at a minimum you will need:
/**
* @NAPIVersion 2.0
* @NModuleScope Public
*/
If you're trying to create a script for one of the standard script types, you'll need to specify that as well like this:
/**
* @NAPIVersion 2.0
* @NModuleScope Public
* @NScriptType ClientScript
*/
You'll also need to expose the appropriate entry point if you're doing this, like pageInit
or beforeLoad
depending on the script type.
NetSuite will prevent you from uploading SuiteScript 2.0 file if it doesn't have the appropriate JSDoc block or entry points.
Upvotes: 1