Rob
09/27/2024, 11:48 AMCeligo AI
09/27/2024, 11:49 AMAI generated answer (using internal Slack threads):To call a RESTlet from a Map/Reduce script in SuiteScript, you can use the
https
module's post
method. However, you need to be aware of the governance units. Each RESTlet call will consume 10 units, and the total units available for a Map/Reduce script are 10,000 for each execute
function.
Here's a sample code snippet on how you can do this:
javascript
var https = require('N/https');
function reduce(context) {
var restletURL = 'https://<ACCOUNT_ID>.<http://app.netsuite.com/app/site/hosting/restlet.nl?script=<SCRIPT_ID>&deploy=<DEPLOY_ID>';|app.netsuite.com/app/site/hosting/restlet.nl?script=<SCRIPT_ID>&deploy=<DEPLOY_ID>';>
var headers = {
'Authorization': 'NLAuth nlauth_account=<ACCOUNT_ID>, nlauth_email=<EMAIL>, nlauth_signature=<PASSWORD>, nlauth_role=<ROLE>'
};
var payload = {
// Your payload here
};
var response = <http://https.post|https.post>({
url: restletURL,
headers: headers,
body: payload
});
log.debug({
title: 'Response',
details: response.body
});
}
Please replace <ACCOUNT_ID>
, <SCRIPT_ID>
, <DEPLOY_ID>
, <EMAIL>
, <PASSWORD>
, and <ROLE>
with your actual values.
Remember, this is just a sample code and you need to handle error scenarios and governance units according to your use case.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
09/27/2024, 11:49 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.835932255
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.833931088
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.83219552
Celigo AI
09/27/2024, 11:49 AM