How can I set a default folder on an image field o...
# ask-stanley-ai
b
How can I set a default folder on an image field on a custom record?
c
AI generated answer (using internal Slack threads):
To set a default folder on an image field on a custom record, you can't directly set the default folder in the UI. However, you can programmatically set the default folder when saving the file. Here's a general idea of how you can do it: 1. Create a SuiteScript that triggers on the afterSubmit event of the record. 2. In the script, get the file from the field. 3. Set the folder on the file using the
folder
property. 4. Save the file. Here's a sample code snippet:
Copy code
javascript
function afterSubmit(context) {
    var record = context.newRecord;
    var fileObj = record.getValue({fieldId: 'custrecord_my_file_field'});
    if (fileObj) {
        fileObj.folder = '123'; // replace with your folder internal id
        fileObj.save();
    }
}
Please replace
'custrecord_my_file_field'
with your actual field id and
'123'
with your actual folder 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.861785531
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.8283
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.813490391
Please provide your feedback on this answer.