Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

netsuite suitescript to upload and rename a file

/**
*@NApiVersion 2.x
*@NScriptType Suitelet
*/
define(['N/ui/serverWidget'],
    function(serverWidget) {
        function onRequest(context) {
            if (context.request.method === 'GET') {
                var form = serverWidget.createForm({
                    title: 'Simple Form'
                });

                var field = form.addField({
                    id: 'custpage_file',
                    type: 'file',
                    label: 'Document'
                });

                form.addSubmitButton({
                    label: 'Submit Button'
                });

                context.response.writePage(form);
            } else {
              var fileObj = context.request.files.custpage_file;
              fileObj.folder = 4601; //replace with own folder ID
              var id = fileObj.save();
            }
    }

    return {
        onRequest: onRequest
    };
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #netsuite #suitescript #upload #rename #file
ADD COMMENT
Topic
Name
1+6 =