Hello, how can I call a SL from a MR? I have tried...
# suitescript
i
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
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
Thats what I was missing, returnExternalURL...
Thanks!
s
I don't think this will work from a MR -> Slt
s
I'm very curious why you would need to call a suitelet from an MR
i
@Shawn Talbert it did work with the external
s
Is it set as 'available without login'?
i
@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
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.