By using the file.createFolder() function, we can programmatically organize the file cabinet by creating new folders under specific parent directories. In the example below, a new folder named “New Folder” is created within a parent folder with the ID 123.
Example:
define(['N/file'], function(file) {
function createFolder() {
var newFolder = file.createFolder({
name: 'New Folder',
parent: 123 // Parent folder ID
});
newFolder.save();
log.debug('Folder Created', newFolder.id);
}
});
The file.createFolder() method specifies the folder name and parent folder ID.
The newFolder.save() command saves the folder to the file cabinet, and log.debug() logs the folder ID.
This functionality is useful for automating the organization of files in NetSuite.