how do I create a new folder via SuiteScript?
# ask-stanley-ai
m
how do I create a new folder via SuiteScript?
c
AI generated answer (using internal Slack threads):
To create a new folder via SuiteScript, you can use the
N/record
module to create a record of type
FOLDER
. Here is a sample code snippet:
Copy code
javascript
var record = require('N/record');

function createFolder(folderName, parentFolderId) {
    var folderRecord = record.create({
        type: record.Type.FOLDER,
        isDynamic: true
    });

    folderRecord.setValue({
        fieldId: 'name',
        value: folderName
    });

    folderRecord.setValue({
        fieldId: 'parent',
        value: parentFolderId
    });

    var folderId = folderRecord.save({
        enableSourcing: true,
        ignoreMandatoryFields: true
    });

    return folderId;
}
In this function,
folderName
is the name of the new folder you want to create, and
parentFolderId
is the internal ID of the parent folder where you want to create the new folder. If you want to create a root folder, you can omit the
parent
field. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.876672149
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.852106571
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.84120518
Please provide your feedback on this answer.