0

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.

Maira S
  • 7
  • 5
  • You can call the suitelet by using url.resolveScript api and pass the parameters to it and get it on your second suitelet using var employee=scriptContext.request.parameters.employees. and can use this variable it in your code – SuiteStar Feb 27 '23 at 11:58

1 Answers1

0

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;
SuiteStar
  • 117
  • 6
  • in parameter left side is keys for your variables that you can use for receiving or getting in the second suitelet. Suppose you are having variable for subsidiary as subsidiary. So you need to put your variable in right side and its unique name in left side as subsidiary data i had put. – SuiteStar Feb 27 '23 at 12:49
  • See @MairaS, I have updated comment in my answer for better understanding. – SuiteStar Feb 27 '23 at 12:51
  • Try by checking its log in your first suitelet that you are being able to send it or not? Then check for receiving. – SuiteStar Feb 27 '23 at 12:59
  • Are you recieving it in second suitelet using var subsidiary=scriptContext.request.parameters.subsidiary_data; log.debug("subsidiary",subsidiary); ? if yes it should work. – SuiteStar Feb 27 '23 at 13:02
  • yes but its not working dear! Debug sub2 2/27/2023 8:07 am Nothing in log Maybe something wrong from my side – Maira S Feb 27 '23 at 13:07
  • Is theer any error you are recieving? – SuiteStar Feb 27 '23 at 13:11
  • hardcoded value passes but not variable value. Getting url like, /app/site/hosting/scriptlet.nf?script=217&deploy=1&compid=ac65623&subsidiary_data= – Maira S Feb 27 '23 at 13:15
  • Once Try by putting parameters unique keys only in quotes like this {"subsidiary_data": subsidiary} – SuiteStar Feb 27 '23 at 13:16
  • put this line returnExternalURL: true for whole url as in code i have updated – SuiteStar Feb 27 '23 at 13:16
  • in url log subsidiary value is not being passed as i can check it shows blank. thats why you are not receiving it.. – SuiteStar Feb 27 '23 at 13:21
  • If you have any value in url it will be visible with dollar symbol in url with unique name – SuiteStar Feb 27 '23 at 13:27
  • @MairaS Is it working for you now? – SuiteStar Feb 27 '23 at 13:48