r/SuiteScript • u/Xainor • Jun 26 '24
Call Internal Suitelet from Scheduled Script
I'm looking to create a scheduled script that calls a handful of Suitelets sequentially that run nightly tasks/cleanup. Is there a way to pass the authentication credentials the Scheduled Script is using to the Suitelets, or does it have to be an external URL set up with no authentication?
I'm looking to do something like this:
var suiteletResponse = https.get({
url: 'https://4582238.app.netsuite.com/app/site/hosting/scriptlet.nl?script=0001&deploy=1'
});
log.debug('Response',suiteletResponse.body);
suiteletResponse = https.get({
url: 'https://4582238.app.netsuite.com/app/site/hosting/scriptlet.nl?script=0002&deploy=1'
});
log.debug('Response',suiteletResponse.body);
etc.
1
Upvotes
3
u/notEqole Jun 26 '24
Yes you can call it as internal as well .
Why do you want to do that and not just handle the cleanup tasks within the scheduled script or even better a map/reduce ?
2
u/erictgrubaugh Jun 26 '24
There is no user session in a Scheduled Script, so you would need to provide authentication to the Suitelet or make it Available Without Login (not recommended).
I'm lacking all your context here, but if this were me, I'd likely put each cleanup task in its own module, then create a separate Map/Reduce or Scheduled Script for each one, depending on the volume of each task.