Post a Suilet from button click

Hello everyone,

 

I have a button on the item record. When clicked, it should open a suitelet in a new window. I have to pass a JSON object as a parameter to the suitelet. So, when using GET, it fails as the URL exceeds the limit. Can anyone tell me how to call a Suitelet using POST and send the parameters (JSON object) from a button click in the client script.

 

Thanks.

Rookie Asked on September 20, 2019 in SuiteScript.
Add Comment
5 Answer(s)
Best answer

Have you reviewed my article that contains the SS2.0 button code pattern?

 

http://blog.prolecto.com/2017/06/10/add-form-button-to-call-netsuite-suitelet/

Beginner Answered on September 22, 2019.
Add Comment

Usually it helps if you share the code you’ve got so far and what you’ve already tried, as well as any errors you’re encountering.

In general, your Client Script will resolve the URL of the Suitelet with N/url and send the POST request using N/https. The parameter that gets passed in to the Suitelet entry point method contains an N/https.ServerRequest which has a method property telling you which type of request you’ve received. You can use this to determine how the Suitelet should respond based on request type.

See the NetSuite Help docs on the Suitelet’s onRequest entry point for details.

Beginner Answered on September 21, 2019.
Add Comment

Do you really need to post it upon button clicked? Then use https.post then put your json in the body then the suitelet invoked will put that json data into the runtime session. Key value pair stored is available in server to server only. Then after invoking the first suitelet. You can now call another suitelet then get the key value pair stored in the runtime session.

Beginner Answered on September 24, 2019.

Thanks for sharing this, this works perfectly!

on December 11, 2019.
Add Comment

I haven’t implemented this in NetSuite but it should be something along the lines as described/answered in this stackexchange post.

Beginner Answered on September 20, 2019.

Thanks for the reply. But I am looking for suitelet side of things. As far I looked anywhere, suitelet is called using Get and on submit, it will be POST.

on September 20, 2019.

Sorry I don’t understand. Why passing suitelet’s url in form’s action attribute not work? Because as far as Suitelet is concerned, you are making a POST request.

on September 20, 2019.
Add Comment

For making a POST request to a Suitelet, @avivashisth provided a good answer, and that’s the approach I would take.

However, one other option if you’d like a different approach would be saving the JSON to a custom record and passing the internal ID of that record as a URL parameter when making a GET request to the Suitelet. Then the Suitelet could load the custom record by internal ID to load the JSON data.

Rookie Answered on September 23, 2019.
Add Comment

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   Become a Sponsor   Become a Sponsor