jhayczee09
09/01/2024, 10:22 AMCeligo AI
09/01/2024, 10:22 AMAI generated answer (using internal Slack threads):To create an upload file page using a Suitelet, you can follow these steps: 1. Create a Suitelet that generates a form using the
N/ui/serverWidget
module. This form should include a file type field for the file upload.
2. The data posted to the Suitelet is available in the onRequest
entry point, specifically in the ServerRequest
found within params.request
. If you want the specific key on the ServerRequest
, you are looking for files
.
3. In your Suitelet, you can retrieve the file object from the request, set the folder where you want to save it in the File Cabinet, and then save it.
Here is a simplified example of how you can do this:
javascript
function onRequest(context) {
if (context.request.method === 'GET') {
var form = serverWidget.createForm({
title: 'Upload File'
});
form.addField({
id: 'custpage_file',
type: serverWidget.FieldType.FILE,
label: 'Select a file'
});
form.addSubmitButton({
label: 'Upload'
});
context.response.writePage(form);
} else {
var fileObj = context.request.files.custpage_file;
fileObj.folder = '-15'; // Set the internal ID of the folder
var fileId = fileObj.save();
context.response.write('File uploaded successfully. File ID is: ' + fileId);
}
}
Please note that the fileObj.folder
should be set to the internal ID of the folder where you want to save the file in the File Cabinet.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
09/01/2024, 10:23 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.853259802
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.837249756
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.834575534
Celigo AI
09/01/2024, 10:23 AM