https://netsuiteprofessionals.com logo
#suitescript
Title
# suitescript
i

irurzo

04/29/2022, 1:57 PM
Hello, how can I call a SL from a MR? I have tried :
Copy code
var suiteletURL = url.resolveScript({
                                scriptId: 'scriptId',
                                deploymentId: 'deployId'
                                });
                            
                              var response = <http://https.post|https.post>({
                                url:suiteletURL,
                                body: params
                              });
This returned an invalid URL, then I added to the URL ->
url: 'https://' + domain + suiteletURL
where domain is
url.resolveDomain({ hostType: url.HostType.APPLICATION });
But this returned on the response a 500 error, then I tried with
redirect.toSuitelet()
but this apparently didnt do nothing. Any idea
s

Sciuridae54696d

04/29/2022, 2:37 PM
https://netsuite.custhelp.com/app/answers/detail/a_id/96933/kw/suitelet%20post does this help?
Copy code
As an alternate solution , we can create a SuiteLet script that can trigger another Suitelet. 

Here is a code snippet used in creating a SuiteLet that would trigger another Suitelet:



 function onRequest(context) {

      var parameters='';

      var suiteletURL = url.resolveScript({

        scriptId:'customscript148',      // Script id of the script that will be triggered

        deploymentId: 'customdeploy1',

        returnExternalUrl: true

      });

      log.debug('suiteletURL', suiteletURL)

      var response1 = <http://https.post|https.post>({  //Sends and http post request 

        url: suiteletURL,

        body: parameters

      });

    } 

    return {

      onRequest: onRequest

    };
That's probably what you need to do, I'd try it with the returnExternalUrl as true
i

irurzo

04/29/2022, 2:56 PM
Thats what I was missing, returnExternalURL...
Thanks!
s

Shawn Talbert

04/29/2022, 3:17 PM
I don't think this will work from a MR -> Slt
s

Sandii

04/29/2022, 4:38 PM
I'm very curious why you would need to call a suitelet from an MR
i

irurzo

04/29/2022, 4:43 PM
@Shawn Talbert it did work with the external
s

Shawn Talbert

04/29/2022, 4:44 PM
Is it set as 'available without login'?
i

irurzo

04/29/2022, 4:44 PM
@Sandii working on a legacy solution, they left a module set up like that, is easier to make it work as it is, than redoing it
@Shawn Talbert yes
s

Shawn Talbert

04/29/2022, 4:46 PM
Ah OK. that explains it. Maybe not a good idea from a security perspective, but my point was authentication would not flow from MR -> Slt automatically.
your case is using no authentication so no issue
you should consider whether bad actors could do anything nefarious via the suitelet - all they need is the url and start hacking away.