Search code examples
javascriptnetsuitesuitescriptsuitescript2.0suitescript1.0

How to post data depending on selected filters on suitelet?


I have created filter fields on suitelet. In filters I select options and then redirect to second suitelet. Filter fields are, subsidiary, location, year and employee designation is 'developer. Now I want to post data depending on option selected in filter and employee's designation is 'developer' to second suitelet.

I have stored selected filters data in variables as,

var subsidiary var location var employees with designation as 'developer

Now I want to post data like, no. of employees which matches depending on selected filters. How to post that data to second suitelet? Please help! I will appreciate your help.


Solution

  • Here is the code sample for calling the suitelet and passing the variable to it. Also how to receive it the suitelet.Use N/redirect module as well for redirecting the current suitelet to called(second) suitelet.

    //call this in your first suitelet and pass your variables.
    var suiteUrl = url.resolveScript({
             scriptId: 'customscript_workorder_multiple_print_sl',
             deploymentId: 'customdeploy_workorder_multiple_print_sl',
             params: {
                 "subsidiary_data": subsidiary,   // left one is unique name and right one is variable.
                 "loaction_data": location,
                 "employee_data": employee,
                },
             returnExternalURL: true
            });
          redirect.redirect({ url: suiteUrl}); // use this to redirect to the new suitelet
    //Then receive it in your second suitelet that you have called like this
    
    var subsidiary=scriptContext.request.parameters.subsidiary_data;  // for recieving it use unique name as here "subsidiary_data"
    var location=scriptContext.request.parameters.loaction_data;
    var employee=scriptContext.request.parameters.employee_data;