create a user event script Using SuiteScript 2.1, ...
# ask-stanley-ai
s
create a user event script Using SuiteScript 2.1, Move files added to the PO and Bill record the have subsidiary with internal Id 5 to a file cabinet folder with the internal ID 100
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems that you want to create a User Event script using SuiteScript 2.1 to move files added to the PO and Bill record that have a subsidiary with internal ID 5 to a file cabinet folder with the internal ID 100. Unfortunately, File or Folder records are not scriptable directly. However, you can create a workaround by creating a File/Document field on a record or Suitelet form and process the file upon submit of that record/Suitelet. Here is a sample code snippet that you can use as a reference:
Copy code
javascript
/**
 * @NApiVersion 2.1
 * @NScriptType UserEventScript
 */
define(['N/record', 'N/file'], function(record, file) {
    function afterSubmit(context) {
        var newRecord = context.newRecord;
        var subsidiary = newRecord.getValue('subsidiary');
        if (subsidiary == 5) {
            var fileId = newRecord.getValue('custbody_file_field'); // replace 'custbody_file_field' with your actual file field id
            if (fileId) {
                var fileObj = file.load({
                    id: fileId
                });
                fileObj.folder = 100; // target folder internal id
                fileObj.save();
            }
        }
    }
    return {
        afterSubmit: afterSubmit
    };
});
This script will be triggered after a record is submitted. It checks if the subsidiary is 5, and if so, it loads the file from the file field, changes the folder to 100, and saves the file. Please replace
'custbody_file_field'
with your actual file field 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.835182905
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.819948375
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.816986084
Please provide your feedback on this answer.