would it be possible to redirect from a Client Scr...
# general
u
would it be possible to redirect from a Client Script to a Suitelet, while passing parameters from the former to the latter?
s
To answer your question simply, yes you can change the navigation with a client script. Simple answer is get the url of your suitelet (N/url is fine here), and set the
window.location.href
in the client script, and append any parameters your would like to the url with
&paramName=paramValue
It is generally odd behavior to have a client script redirect to a page though, what entry point would you like to trigger the redirect.
u
hi, thanks for the response. I'm currently trying to generate a PDF from a Price Quote. I have a UserEvent that generates the button, then add the button function via Client Script, then add the logic and rendering thru the Suitelet. Unless you have better ideas, thanks for the answer!
for the entry point, onRequest should be fine. I really just need it to render the pdf.
t
You do not need client script. You can directly set a function name on the button. Something like this:
Copy code
//Suitelet
var urlSuiteLet = url.resolveScript({
   scriptId: 'customscript_ns_sl_print_ship_inv',
   deploymentId: 'customdeploy_ns_sl_print_ship_inv',
   returnExternalUrl: false,
   params: {
      transactionId: recCurrent.id,
   }
});

objForm.addButton({
   id: 'custpage_printshipinvoice',
   label: 'Print Ship Invoice',
   functionName: "window.open('" + urlSuiteLet + "','_blank')"
});