Download a sublist data in a CSV file format after “Download Report” button click on suitelet

1

 

I have created a Suitelet script in NetSuite that populates a sublist based on values entered into a textarea field and submitted via a button. This part of the script functions correctly. The sublist population logic is handled within the POST method.

 

Now, I need to add a “Download CSV” button to the Suitelet. Upon clicking this button, the user should be able to download the data displayed in the populated sublist as a CSV file.

 

How can I implement the logic to generate and trigger the download of the sublist data in CSV format after the “Download CSV” button is clicked within the Suitelet?”

//Suitelet Code Sample

 function onRequest(context) {

            // Add Textarea ABC Number field

            let ABCField = form.addField({

                id: ‘custpage_input_cidn’,

                type: serverWidget.FieldType.TEXTAREA,

                label: ‘Enter ABC Numbers’

            });

 

            // Add Submit Button

            form.addSubmitButton({ label: ‘Submit’ });

 

            // Add empty sublist

            let sublist = form.addSublist({

                id: ‘custpage_results_sublist’,

                type: serverWidget.SublistType.LIST,

                label: ‘Sales Order Items’

            });

 

            //Remaining logic to add fields to sublist

 

             if (context.request.method === ‘POST’) {

             //Logic to set sublists based on entered ABC Numbers

             }

             context.response.writePage(form);

            }

 

Beginner Asked on April 3, 2025 in SuiteScript.
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   SuiteMigration   Become a Sponsor