Brekk - After making the RESTlet call, include a SuiteScript step to handle the response. Extract relevant data from the answer and store it in the mobile action's state.
E.g.
/**
* SuiteScript 2.0 code snippet to handle RESTlet response and store in the mobile action state.
*/
/**
* @NApiVersion 2.x
* @NScriptType Suitelet
*/
define(['N/record', 'N/log', 'N/https', 'N/url'],
function(record, log, https, url) {
function onRequest(context) {
// Make a RESTlet call
var restletUrl = 'https://<ACCOUNT_ID>.
suitetalk.api.netsuite.com/app/site/hosting/restlet.nl?script=<SCRIPT_ID>&deploy=<DEPLOYMENT_ID>';
var response = https.get({ url: restletUrl });
// Extract data from the RESTlet response
var responseData = response.body; // Adjust this based on the actual structure of your response
// Store the data in the mobile action state
var mobileAction = context.request.parameters.mobileAction; // Adjust this based on the actual parameter name
var state = context.request.parameters.state; // Adjust this based on the actual parameter name
// Store the response data in the state
state.myCustomData = responseData; // Adjust this based on the actual structure of your response
context.response.write('RESTlet response stored in state.');
}
return {
onRequest: onRequest
};
}
);