file.copy(options)
Method Description |
Copy an existing file in the NetSuite File Cabinet. When you copy a file using this method, the copied file has the same properties as the original file. For example, if the original file is available without login, the copied file is also available without login. You can use the file.NameConflictResolution enum to specify how to resolve conflicts when copying files. A conflict occurs when the target folder for a copy operation already contains a file with the same name as the file to copy. When a conflict occurs, you can specify how the conflict is resolved. For example, you can specify that the copy operation should fail if a conflict occurs. |
Returns |
|
Supported Script Types |
Server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
20 units |
Module |
|
Since |
2021.1 |
Parameters
The options parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
number |
required |
The internal ID of the folder to copy the file to. This folder must already exist in the File Cabinet. |
2021.1 |
|
number |
required |
The internal ID of the file to copy. This file must already exist in the File Cabinet. |
2021.1 |
|
string |
optional |
The conflict resolution value. This parameter specifies the type of conflict resolution to apply when a conflict occurs while copying a file (for example, if the target folder already contains a file with the same name). Use the values in the file.NameConflictResolution enum to set this parameter. The default value is |
2021.1 |
Errors
Error Code |
Thrown If |
---|---|
|
A value is specified for the |
|
A required argument is not passed. |
Syntax
The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/file Module Script Samples.
// Add additional code
...
var fileObj = file.create({
name: 'test.txt',
fileType: file.Type.PLAINTEXT,
contents: 'Hello World\nHello World'
});
fileObj.folder = -15;
var id = fileObj.save();
fileObj = file.copy({
id: id,
folder: -4,
conflictResolution: file.ConflictResolution.FAIL
});
...
// Add additional code