How to remove a folder from file cabinet using suitescript?

To remove a folder from the File Cabinet using SuiteScript, you can use the N/record module. The following code demonstrates how to delete a folder:

/**
 * Remove a folder from the File Cabinet
 * @param {string} folderId - The internal id of the folder to be removed
 */
function removeFolder(folderId) {
record.delete({
       type: record.Type.FOLDER,
       id: folderId,
    });
  }

  try {
    removeFolder(12345); //12345 - folder internal id
    log.debug('Folder Removed', 'Folder with id' + 12345 + ' has been successfully removed.');
  } catch (error) {
    log.error('Folder Removal Failed', 'An error occurred while removing folder with id' + folderId + ': ' + error.message);
  }
}


Leave a comment

Your email address will not be published. Required fields are marked *