i would like to change the parent folder of a spec...
# ask-stanley-ai
s
i would like to change the parent folder of a specific folder in the file cabinet. I'm currently able to do that on a non root directory but for a root directory i get the following error "FOLDER_DOES_NOT_EXIST_OR_YOU_DON_T_HAVE_ACCESS_TO_THE_FOLDER" I'm running the script as a administrator so i should have access. this is the code i used var rec = record.load({ type: record.Type.FOLDER, id: 16578399, }); rec.setValue({ fieldId:"parent", value: 4074930 }) rec.save()
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems like you're trying to change the parent folder of a root directory in the file cabinet. However, you're encountering an error that says "FOLDER_DOES_NOT_EXIST_OR_YOU_DON_T_HAVE_ACCESS_TO_THE_FOLDER". This error typically occurs when the folder you're trying to access doesn't exist or you don't have the necessary permissions to access it. Since you're running the script as an administrator, it's likely that the folder doesn't exist. In your code, you're trying to load a folder with the ID 16578399 and then change its parent to a folder with the ID 4074930. Please ensure that both these folders exist in your file cabinet. If you're trying to change the parent of a root directory, it's important to note that root directories in the file cabinet don't have a parent folder. They are the top-level folders in the file cabinet hierarchy. Therefore, trying to change their parent folder might not be possible. Here's a sample code snippet that shows how to create a folder in a specific directory:
Copy code
javascript
function createFolderPerCustomer(_customerName_) {
    const objRecord = _record_.create({
        type: _record_.Type.FOLDER,
        isDynamic: true
    });

    objRecord.setValue({
        fieldId: 'name',
        value: _customerName_
    });

    objRecord.setValue({
        fieldId: 'parent',
        value: _parentFolderId_ // replace with your parent folder's internal ID
    });

    const folderId = objRecord.save({
        enableSourcing: true,
        ignoreMandatoryFields: true
    });

    return folderId;
}
In this code, we're creating a new folder with the specified customer name and saving it in a specific parent directory. The parent directory is specified by its internal ID. ****** 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.847576916
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.825306118
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.814479053
Please provide your feedback on this answer.
Thank you for your feedback